Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Basic Standards for Web Services CS 696 – Services Computing Fall 2008 Chapter 2: Service-Oriented Computing: Semantics, Processes, Agents – Munindar.

Similar presentations


Presentation on theme: "1 Basic Standards for Web Services CS 696 – Services Computing Fall 2008 Chapter 2: Service-Oriented Computing: Semantics, Processes, Agents – Munindar."— Presentation transcript:

1 1 Basic Standards for Web Services CS 696 – Services Computing Fall 2008 Chapter 2: Service-Oriented Computing: Semantics, Processes, Agents – Munindar P. Singh and Michael N. Huhns, Wiley, 2005

2 2 Highlights of this Chapter eXtensible Markup Language (XML) Simple Object Access Protocol (SOAP) Web Services Description Language (WSDL) Directory Services Universal Description, Discovery, and Integration (UDDI)

3 3 Standards for Web Services

4 4 XML Web Service Foundation Open and with broad industry support Publish, Find, Use Services UDDI Service Interactions SOAP Universal Data Format XML Description Language WSDL Ubiquitous Communications TCP/IP, HTTP, SMTP, SIP, Reliable messaging Security (authentication and authorization) WS-Security, SAML

5 5 Markup History None, as in comma separated values Ad hoc tags SGML (Standard Generalized Markup L): complex, few reliable tools HTML (HyperText ML): simple, unprincipled, mixes structure and display XML (eXtensible ML): simple, yet extensible subset of SGML to capture new vocabularies Machine processible Comprehensible to people: easier debugging

6 6 Brief Introduction to XML Basics Parsing Storage Transformations

7 7 XML Basics and Namespaces <!– not part of the document per se  <arbitrary:toptag xmlns=“http://one.default.namespace/if-needed” xmlns:arbitrary=“http://wherever.it.might.be/arbit-ns” xmlns:random=“http://another.one/random-ns”> Optional text also known as PCDATA <!–compare with arbitrary:atag 

8 8 XML Example 25 2

9 9 XML Example 25

10 10 HTML Example of same data Value Accuracy Scale Ambience Condition 25 2 Celsius Shade

11 11 XML Query Languages XPath XPointer XSLT XQuery

12 12 XPath Model XML documents as trees with nodes Elements Attributes Text (PCDATA) Comments Root node: above root of document

13 13 XPath Parent in XPath is like parent as traditionally in computer science Child in XPath is confusing: An attribute is not the child of its parent Makes a difference for certain kinds of recursion (e.g., apply-templates discussed in XSLT)

14 14 XPath Paths Leading /: root /: indicates walking down a tree.:current node..:parent node @attr: to access values for the given attribute text() comment()

15 15 XPath Navigation Select children according to position, e.g., [j], where j could be 1 … last() Descendant-or-self operator, //.//elem finds all elems under the current //elem finds all elems in the document Wildcard, *: @*: finds all attribute values

16 16 XPath Queries Incorporate selection conditions in XPath Attributes: //Song[@genre=“jazz”] Elements: //Song[starts-with(.//group, “Led”)] Existence of attribute: //Song[@genre] Existence of subelement: //Song[group] Boolean operators: and, not, or Set operator: union (|); none others Arithmetic operators: >, <, … String functions: contains(), concat(), length(), Aggregates: sum(), count()

17 17 XPointer Combines XPath with URLs URL to get to a document; XPath to walk down the document Can be used to formulate queries, e.g., Song- URL#xpointer(//Song[@genre=“jazz”])

18 18 XSLT A functional programming language A stylesheet specifies transformations on a document <?xml-stylesheet type=“text/xsl” href=“URL-to-dot-xsl”?> <!– the sheet to use  …

19 19 XSLT Stylesheets Use the XSLT namespace, conventionally abbreviated as xsl Includes primitives: Copy-of

20 20 XML file referencing XSL stylesheet 25 2 123 5 32 1

21 21 Stylesheet (TempTable.xsl) http://www.w3.org/1999/XSL/Transform Value Accuracy Scale

22 22 XSLT Templates: 1 A pattern to specify where a given transform should apply This match only works on the root: …

23 23 XSLT Templates: 2 Can be applied recursively on the children via By default, if no other template matches, recursively apply to children of current node (ignores attributes) and to root:

24 24 Parsing and Validating An XML document maps to a parse tree. Each tag ends once: nesting structure (one root) Each attribute occurs at most once; quoted string Well-formed XML documents can be parsed Applications have an explicit or implicit syntax for their particular XML-based tags If explicit, may be expressed in DTDs and XML Schemas Best referred to definitions elsewhere XML Schemas, expressed in XML, are superior to DTDs When docs are produced by external components, they should be validated

25 25 DTD (Document Type Definition) Example 25 2  #PCDATA – Parsed Character data, can contain markup  CDATA – Character data, is not parsed for markup

26 26 XML Schema A data definition language for XML: defines a notion of schema validity; helps us define desired grammars for documents Same syntax as regular XML documents Local scoping of subelement names Incorporates namespaces Types Primitive (built-in): string, ID, IDREF, integer, float, date, simpleType constructors: list, union Restrictions: intervals, lengths, enumerations, regex patterns, Flexible ordering of elements Key and referential integrity constraints

27 27 XML Schema example <xsd:schema xmlns:xsd=“http://www.w3.org/2001/XMLSchema”http://www.w3.org/2001/XMLSchema … >

28 28 XML Schema example

29 29 XML Schema: complexType Specifies types of elements with structure: Must use a compositor if > 1 subelements Subelements with types Min and max occurrences (default 1) of subelements

30 30 XML Schema: Compositors Sequence: ordered Can occur within other compositors Allows varying min and max occurrence All: unordered Must occur directly below root element Max occurrence of each element is 1 Choice: exclusive or Can occur within other compositors

31 31 XML Schema: Key Namespaces http://www.w3.org/2001/XMLSchema Conventional prefix: xsd Terms for defining schemas: schema, element, attribute, … The tag schema has an attribute targetNamespace http://www.w3.org/2001/XMLSchema- instance Conventional prefix: xsi Terms for use in instances: schemaLocation, null targetNamespace: user-defined

32 32 XML Schema Instance Doc <Music xmlns=http://a.b.c/Muse xmlns:xsi=“the standard-xsi” xsi:schemaLocation=“a-schema-as-a-URI a-schema-location-as-a-URL”> …

33 33 Creating Schema Docs: 1 <schema xmlns=“the-standard-xsd” targetNamespace=“the-target”>

34 34 Creating Schema Docs: 2 Use imports instead of include Specify namespaces from which schemas are to be imported Location of schemas not required and may be ignored if provided

35 35 Document Object Model (DOM) Basis for parsing XML, which provides a node- labeled tree in its API Conceptually simple: traverse by requesting tag, its attribute values, and its children Processing program reflects document structure Can edit documents Inefficient for large documents: parses them first entirely to build the tree even if a tiny part is needed

36 36 DOM Example [Simeoni 2003] Element s = d.getDocumentElement(); NodeList l = s.getElementsByTagName(“member”); Element m = (Element) l.item(0); int code = m.getAttribute(“code”); NodeList kids = m.getChildNodes(); Node kid = kids.item(0); String tagName = ((Element)kid).getTagName(); …

37 37 Simple API for XML (SAX) Parser generates a sequence of events: startElement, endElement, … Programmer implements these as callbacks More control for the programmer Processing program does not reflect document structure

38 38 SAX Example [Simeoni 2003] class MemberProcess extends DefaultHandler { public void startElement (String uri, String n, String qName, Attributes attrs) { if (n.equals(“member”)) code = attrs.getValue(“code”); if (n.equals(“project”)) inProject = true; buffer.reset(); } public void endElement (String uri, String n, String qName) { if (n.equals(“project”)) inProject = false; if (n.equals(“member”) && !inProject) name = buffer.toString().trim(); } }

39 39 Programming with XML Current approaches concentrate on structure but ignore meaning Difficult to construct and maintain Treat everything as a string Inadequate type checking can hide errors Emerging approaches (e.g., JAXB) provide superior binding from XML to programming languages Primitives such as unmarshal to materialize an object from XML

40 40 Uses of XML Exchanging information across software components Storing information in nonproprietary format XML documents represent structured descriptions: Products, services, catalogs Contracts Queries, requests, invocations (as in SOAP) Data-centric versus document-centric (irregular, heterogeneous data, depend on entire doc for app-specific meaning) views

41 41 Data-Centric View V11 … V1n … Vm1 … Vmn Extract and store into DB via mapping to DB model Regular, homogeneous tags May be expensive if repeatedly parsed and instantiated

42 42 Document-Centric View Storing docs in DBs Use character large objects (clobs) within DB Store paths to external files containing docs Combine with some structured elements with search conditions for both structured elements and unstructured clobs or files Heterogeneity also complicates mappings to traditional typed OO programming languages

43 43 Directions Limitations of XML Doesn’t represent meaning Enables multiple representations for the same information; transform if models known Trends: sophisticated approaches for Querying and manipulating XML, e.g., XSLT Binding to PLs and DBs Semantics, e.g., RDF, DAML, OWL, …

44 44 XML Summary XML enables information sharing XML is well established Several aspects are worked out Lots of tools Works with databases and programming languages XML provides a useful substrate for service-oriented computing

45 45 Web Services: Basic Architecture Service Broker Service Provider Service Requestor Bind or invoke (SOAP) Find or discover (UDDI) Publish or announce (WSDL) Registry; well-known Not well-known

46 46 Basic Profile (BP 1.0) The Web Services Interoperability Organization (WS-I) has specified the following Basic Profile version 1.0: SOAP 1.1 HTTP 1.1 XML 1.0 XML Schema Parts 1 and 2 UDDI Version 2 WSDL 1.1

47 47 Describing a Service Name e.g., GetTemperature Types of Input Parameters e.g., (String, String) Types of Output Parameters e.g., Integer

48 48 Interactions Via Methods Via Messages Purchasing() CatalogService() Order() invoke invoke catalog confirmation #

49 49 SOAP (Simple Object Access Protocol) Used to exchange messages via HTTP, SMTP, and SIP (Session Initiation Protocol for Internet telephony) Originally designed for remote-procedure calls (RPC) Works through firewalls on port 80 Character-based, so easy to encrypt/decrypt and thus easy to secure Inefficient due to character, not binary, data and large headers Does not describe bidirectional or n-party interaction

50 50 Ex. SOAP Request POST /temp HTTP/1.1 Host: www.socweather.com Content-Type: text/xml; charset="utf-8" Content-Length: xxx SOAPAction: "http://www.socweather.com/temp" <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> Honolulu now

51 51 Ex. SOAP Response HTTP/1.1 200 OK Content-Type: text/xml; charset="utf-8" Content-Length: xxx SOAPAction: "http://www.socweather.com/temp" <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> <m:GetTempResponse xmlns:m="http://www.socweather.com/temp.xsd"> 30

52 52 WSDL: Web Services Description Language Describes a programmatic interface to a Web service, including Definitions of data types Input and output message formats The operations provided by the service Network addresses Protocol bindings

53 53 WSDL Data Model

54 54 WSDL Example <wsdl:definitions name="Temperature" targetNamespace="http://www.socweather.com/schema" xmlns:ts="http://www.socweather.com/TempSvc.wsdl" xmlns:tsxsd="http://schemas.socweather.com/TempSvc.xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">

55 55 WSDL Example <xsd:schema targetNamespace="http://namespaces.socweather.com" xmlns:xsd="http://www.w3.org/1999/XMLSchema">

56 56 WSDL Example

57 57 WSDL Example <!-- The order of input and output is significant;

58 58 WSDL Example

59 59 WSDL Example socweather.com temperature service

60 60 Directory Services Support discovery: enable applications, agents, Web service providers, Web service requestors, people, objects, and procedures to locate each other White pages – entries found by name Yellow pages – entries found by characteristics and capabilities A basic directory might be a simple database (passive) or a broker/facilitator (active, that provides alerts and recruits participants) UDDI – both white pages and yellow pages, but passive


Download ppt "1 Basic Standards for Web Services CS 696 – Services Computing Fall 2008 Chapter 2: Service-Oriented Computing: Semantics, Processes, Agents – Munindar."

Similar presentations


Ads by Google