1 / 46

EEC-681/781 Distributed Computing Systems

This lecture discusses the basics of web services and XML, including SOAP, WSDL, UDDI, and the benefits of using web services in distributed computing systems.

clydew
Download Presentation

EEC-681/781 Distributed Computing Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. EEC-681/781Distributed Computing Systems Lecture 7 Wenbing Zhao wenbing@ieee.org (Lecture nodes are based on materials obtained from http://www.w3schools.com)

  2. Outline • Introduction to Web services • XML, SOAP, WSDL, UDDI • Reminder: • Midterm #1: Oct 8, 6-8pm EEC-681: Distributed Computing Systems

  3. Web Services • Web services are application components • Web services communicate using open protocols • Web services are self-contained and self-describing • Web services can be discovered using UDDI • Web services can be used by other applications • XML is the basis for Web services • Focuses on messages and documents, not on APIs EEC-681: Distributed Computing Systems

  4. How Does it Work? • The basic Web services platform is XML + HTTP • The HTTP protocol is the most used Internet protocol • XML provides a language which can be used between different platforms and programming languages and still express complex messages and functions EEC-681: Distributed Computing Systems

  5. Web Services Platform Elements • SOAP (Simple Object Access Protocol) • WSDL (Web Services Description Language) • UDDI (Universal Description, Discovery and Integration) EEC-681: Distributed Computing Systems

  6. Why Web Services? • Enables maximum interoperability of Web applications • Based on standard: SOAP, WSDL, UDDI • Requires minimum infrastructure • Shorter learning curve, easier to maintain • Highly extensible and very low level of application integration • Enable adaptable and upgradeable apps EEC-681: Distributed Computing Systems

  7. What is XML? • XML is a text-based Extensible Markup Language • Similar to HTML, an XML file consists of tags, i.e., identifiers enclosed in angle brackets <…> • XML tags identify data only, it does not specify how to display it (start) tag <message> <to>you@yourAddress.com</to> <from>me@myAddress.com</from> <subject>XML Is Really Cool</subject> <text> How many ways is XML cool? ...</text> </message> (end) tag EEC-681: Distributed Computing Systems

  8. XML Syntax • Element: A unit of XML data, delimited by tags • An XML element can enclose other elements • Attribute: A tag can contain attributes. An attribute is A qualifier on an XML tag that provides additional information • For example, in the tag <slide title="My Slide">, title is an attribute, and My Slide is its value <message to="you@yourAddress.com"from="me@myAddress.com"subject="XML Is Really Cool"> <text> How many ways is XML cool? ... </text> </message> Element EEC-681: Distributed Computing Systems

  9. XML Syntax • Empty tag: an element with no data value • <flag/> is equivalent to <flag></flag> • An XML document must be well-formed, i.e. for each tag, there must be a corresponding end tag, unless it is an empty tag • Comment: same as HTML comment • <!-- This is a comment --> • Prolog: each XML document must have a prolog preceding XML data. A prolog contains a declaration and an optional DTD • <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?> EEC-681: Distributed Computing Systems

  10. XML Syntax • Document Type Definition (DTD): specifies • The kinds of tags that can be included in the XML document, and • The valid arrangements of those tags • There are many alternatives to DTD, such as XML Schema EEC-681: Distributed Computing Systems

  11. Why XML • Extensibility • Self describing structured data • Support hierarchical structure • Easy to edit and debug • Easy to process • Separation of data and formatting information (not relevant to Web Services) EEC-681: Distributed Computing Systems

  12. Processing XML Document • An XML document can be accessed either serially or in random access mode • Simple API for XML (SAX) • Serial access and event driven • Document Object Model (DOM) • Convert XML document into a collection of objects, allows random access and modification EEC-681: Distributed Computing Systems

  13. What is SOAP? • SOAP stands for Simple Object Access Protocol • SOAP is a communication protocol • SOAP is for communication between applications • SOAP is a format for sending messages • SOAP is designed to communicate via Internet • SOAP is platform independent • SOAP is language independent • SOAP is based on XML • SOAP is simple and extensible • SOAP allows you to get around firewalls EEC-681: Distributed Computing Systems

  14. Why SOAP? • SOAP is designed specifically to enable applications to communicate over Internet • SOAP runs on top of HTTP and other protocols such as SMTP and FTP • Older middleware-level protocols, such as CORBA and DCOM, are not designed for to run on HTTP • Firewalls are not friendly to such messages EEC-681: Distributed Computing Systems

  15. SOAP Envelope SOAPheader Header Block Body Block SOAPBody SOAP Building Blocks • A SOAP message is an XML document containing the following elements: • A requiredEnvelope element that identifies the XML document as a SOAP message • An optionalHeader element that contains header information • A requiredBody element that contains call and response information • An optionalFault element that provides information about errors that occurred while processing the message EEC-681: Distributed Computing Systems

  16. SOAP Syntax Rules • A SOAP message • MUST be encoded using XML • MUST use the SOAP Envelope namespace • MUST use the SOAP Encoding namespace • Must NOT contain a DTD reference • Must NOT contain XML Processing Instructions EEC-681: Distributed Computing Systems

  17. Skeleton SOAP Message <?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope“ soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:Header> … … </soap:Header> <soap:Body> ... ... <soap:Fault> ... ... </soap:Fault> </soap:Body> </soap:Envelope> EEC-681: Distributed Computing Systems

  18. SOAP Envelope Element • It is required and it is the root element of a SOAP message • It defines the XML document as a SOAP message • It must specify the mandatory namespace <?xml version="1.0"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope“ soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding"> … Message information goes here … </soap:Envelope> • The SOAP encodingStyle attribute is used to define the data types used in the document EEC-681: Distributed Computing Systems

  19. SOAP Namespace • Most elements in a soap message are required to be namespace-qualified in the form ns:tag • You need to define the namespace only once in a message <soap:Envelope xmlns:soap=http://schemas.xmlsoap.org/soap/envelope> namespace Namespace definition (SOAP default namespace) <soapenv:Envelopexmlns:soapenv=http://schemas.xmlsoap.org/soap/envelope> It doesn’t matter what name you use EEC-681: Distributed Computing Systems

  20. SOAP Header Element • The SOAP Header element is optional • The header element contains application specific information about the SOAP message • E.g. authentication, coordination, etc. • If the Header element is present, it must be the first child element of the Envelope element EEC-681: Distributed Computing Systems

  21. SOAP Header Element • The actor attribute • It is used to address the Header element to a particular endpoint along the message path • The mustUnderstand attribute • It is used to indicate whether a header entry is mandatory or optional for the recipient to process EEC-681: Distributed Computing Systems

  22. SOAP Body Element • It is required • It contains actual SOAP message intended for the ultimate endpoint of the message • Immediate child elements of the SOAP Body element may be namespace-qualified • SOAP defines the Fault element inside the Body element in the default namespace EEC-681: Distributed Computing Systems

  23. SOAP Fault Element • The Fault element (if present) carries an error message • If present, it is embedded in the Body element as a child element • A Fault element can only appear once in a SOAP message EEC-681: Distributed Computing Systems

  24. SOAP Fault Element • The SOAP Fault element has the following sub elements EEC-681: Distributed Computing Systems

  25. SOAP Fault Element • SOAP Fault Codes EEC-681: Distributed Computing Systems

  26. HTTP Protocol • HTTP communicates over TCP/IP • An HTTP client connects to an HTTP server using TCP • After establishing a connection, the client can send an HTTP request message to the server: POST /item HTTP/1.1 Host: 137.148.142.239 Content-Type: text/plain Content-Length: 200 EEC-681: Distributed Computing Systems

  27. HTTP Protocol • The server then processes the request and sends an HTTP response back to the client • The response contains a status code that indicates the status of the request: • In the example above, the server returned a status code of 200. This is the standard success code for HTTP • If the server could not decode the request, it could have returned something like this: 200 OK Content-Type: text/plain Content-Length: 200 400 Bad Request Content-Length: 0 EEC-681: Distributed Computing Systems

  28. HTTP POST SOAP Envelope SOAPheader Transactional context SOAPBody Name of Procedure Input parameter 1 Input parameter 2 SOAP HTTP Binding • A SOAP method call is an HTTP request/response that complies with SOAP encoding rules • HTTP + XML = SOAP • A SOAP request could be an HTTP POST or an HTTP GET request • The HTTP POST request specifies at least two HTTP headers: • Content-Type and Content-Length EEC-681: Distributed Computing Systems

  29. SOAP HTTP Binding • Content-Type header: defines the MIME type for the SOAP message and the character encoding (optional) used for the XML body of the request or response • Syntax: • Example: Content-Type: MIMEType; charset=character-encoding POST /item HTTP/1.1 Content-Type: application/soap+xml; charset=utf-8 MIME : Multipurpose Internet Mail Extensions EEC-681: Distributed Computing Systems

  30. SOAP HTTP Binding • Content-Length header: specifies the number of bytes in the body of the request or response • Syntax: • Example: Content-Length: bytes POST /item HTTP/1.1 Content-Type: application/soap+xml; charset=utf-8 Content-Length: 250 EEC-681: Distributed Computing Systems

  31. What is WSDL? • WSDL stands for Web Services Description Language • WSDL is written in XML • WSDL is an XML document • WSDL is used to describe Web services • WSDL is also used to locate Web services EEC-681: Distributed Computing Systems

  32. WSDL Document Structure • A WSDL document describes a web service using these major elements: Service Port (e.g. http://host/svc) Port Binding (e.g. SOAP) Binding Abstract interface portType operation(s) inMesage outMessage EEC-681: Distributed Computing Systems

  33. WSDL Ports • The <portType> element describes a web service • The operations that can be performed, and • The messages that are involved • It can be compared to a function library (or a class) in a traditional programming language <portType name="GetQuote"> <operation name="getQuote" > <input message="tns:GetQuoteRequest"/> <output message="tns:GetQuoteResponse"/> </operation> </portType> EEC-681: Distributed Computing Systems

  34. WSDL Messages • The <message> element defines the data elements of an operation • Each message can consist of one or more parts • The parts can be compared to the parameters of a function call in a traditional programming language <message name="GetQuoteRequest"> <part name="symbol" type="xsd:string"/> </message> <message name="GetQuoteResponse"> <part name="result" type="xsd:float"/> </message> EEC-681: Distributed Computing Systems

  35. WSDL Types • The <types> element defines the data type used by the web service • For maximum platform neutrality, WSDL uses XML Schema syntax to define data types <wsdl:types> <xs:schema> <xs:import namespace='http://schemas.xmlsoap.org/ws/2004/08/addressing' schemaLocation='addr.xsd' /> </xs:schema> </wsdl:types> EEC-681: Distributed Computing Systems

  36. WSDL Ports – Operation Types • WSDL defines four operation types EEC-681: Distributed Computing Systems

  37. One-Way Operation <message name="newTermValues"> <part name="term" type="xs:string"/> <part name="value" type="xs:string"/> </message> <portType name="glossaryTerms"> <operation name="setTerm"> <input name="newTerm" message="newTermValues"/> </operation> </portType > Input only EEC-681: Distributed Computing Systems

  38. Request-Response Operation <message name="getTermRequest"> <part name="term" type="xs:string"/> </message> <message name="getTermResponse"> <part name="value" type="xs:string"/> </message> <portType name="glossaryTerms"> <operation name="getTerm"><input message="getTermRequest"/> <output message="getTermResponse"/> </operation></portType> Input and output EEC-681: Distributed Computing Systems

  39. WSDL Bindings • WSDL bindings (<binding> element) defines the message format and protocol details for a web service • Many different bindings are defined: SOAP, HTTP and MIME EEC-681: Distributed Computing Systems

  40. Binding to SOAP <binding type="glossaryTerms" name="b1"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> <operation> <soap:operation soapAction="http://example.com/getTerm"/> <input> <soap:body use="literal"/> </input> <output> <soap:body use="literal"/> </output> </operation> </binding> EEC-681: Distributed Computing Systems

  41. Binding to SOAP • Thebinding element has two attributes: • Name attribute (you can use any name you want) defines the name of the binding • Type attribute points to the port for the binding, in this case the "glossaryTerms" port <binding type="glossaryTerms" name="b1"> EEC-681: Distributed Computing Systems

  42. Binding to SOAP • The soap:binding element has two attributes: • Style attribute can be "rpc" or "document" • Transport attribute defines the transport protocol to use <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> EEC-681: Distributed Computing Systems

  43. Binding to SOAP <operation> <soap:operation soapAction="http://example.com/getTerm"/> <input> <soap:body use="literal"/> </input> <output> <soap:body use="literal"/> </output> </operation> • Theoperation element defines each operation that the port exposes • You must define a SOAP action for each operation • You must also specify how the input and output are encoded Literal encoding: uses a XML Schema to validate SOAP data EEC-681: Distributed Computing Systems

  44. UDDI • Universal Description, Discovery and Integration (UDDI) is a directory service where businesses can register and search for Web services • UDDI uses WSDL to describe interfaces to web services • UDDI communicates via SOAP EEC-681: Distributed Computing Systems

  45. UDDI Benefits • Describing services and business processes programmatically in a single, open, and secure environment • Making it possible to discover the right business from the millions currently online • Reaching new customers and increasing access to current customers • Allowing for rapid participation in the global Internet economy EEC-681: Distributed Computing Systems

  46. References • XML: http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/index.html • SOAP: http://www.w3schools.com/soap/default.asp • WSDL and UDDI:http://www.w3schools.com/wsdl/default.asp EEC-681: Distributed Computing Systems

More Related