Presentation is loading. Please wait.

Presentation is loading. Please wait.

EEC-681/781 Distributed Computing Systems Lecture 7 Wenbing Zhao (Lecture nodes are based on materials obtained from

Similar presentations


Presentation on theme: "EEC-681/781 Distributed Computing Systems Lecture 7 Wenbing Zhao (Lecture nodes are based on materials obtained from"— Presentation transcript:

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

2 2 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Outline Introduction to Web services –XML, SOAP, WSDL, UDDI Reminder: –Midterm #1: Oct 8, 6-8pm

3 3 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao 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

4 4 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao 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

5 5 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Web Services Platform Elements SOAP (Simple Object Access Protocol) WSDL (Web Services Description Language) UDDI (Universal Description, Discovery and Integration)

6 6 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao 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

7 7 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao 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 you@yourAddress.com me@myAddress.com XML Is Really Cool How many ways is XML cool?... (start) tag (end) tag

8 8 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao 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, title is an attribute, and My Slide is its value How many ways is XML cool?... Element

9 9 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao XML Syntax Empty tag: an element with no data value – is equivalent to –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 – Prolog: each XML document must have a prolog preceding XML data. A prolog contains a declaration and an optional DTD –

10 10 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao 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

11 11 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao 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)

12 12 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao 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

13 13 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao 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

14 14 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao 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

15 15 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao SOAP Building Blocks A SOAP message is an XML document containing the following elements: –A required Envelope element that identifies the XML document as a SOAP message –An optional Header element that contains header information –A required Body element that contains call and response information –An optional Fault element that provides information about errors that occurred while processing the message SOAP Envelope SOAP header Header Block SOAP Body Body Block

16 16 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao 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

17 17 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Skeleton SOAP Message <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope“ soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> … ….........

18 18 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao 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 <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope“ soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding"> … Message information goes here … The SOAP encodingStyle attribute is used to define the data types used in the document

19 19 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao 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 http://schemas.xmlsoap.org/soap/envelope namespace Namespace definition (SOAP default namespace) http://schemas.xmlsoap.org/soap/envelope It doesn’t matter what name you use

20 20 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao 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

21 21 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao 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

22 22 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao 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

23 23 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao 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

24 24 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao SOAP Fault Element The SOAP Fault element has the following sub elements Sub ElementDescription A code for identifying the fault A human readable explanation of the fault Information about who caused the fault to happen Holds application specific error information related to the Body element

25 25 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao SOAP Fault Element SOAP Fault Codes ErrorDescription VersionMismatchFound an invalid namespace for the SOAP Envelope element MustUnderstandAn immediate child element of the Header element, with the mustUnderstand attribute set to "1", was not understood ClientThe message was incorrectly formed or contained incorrect information ServerThere was a problem with the server so the message could not proceed

26 26 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao 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

27 27 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao 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

28 28 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao 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 SOAP Envelope SOAP header Transactional context SOAP Body Input parameter 1 Input parameter 2 Name of Procedure HTTP POST

29 29 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao 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: POST /item HTTP/1.1 Content-Type: application/soap+xml; charset=utf-8 Content-Type: MIMEType; charset=character-encoding MIME : Multipurpose Internet Mail Extensions

30 30 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao 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

31 31 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao 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

32 32 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao WSDL Document Structure A WSDL document describes a web service using these major elements: ElementDefines Operations performed by the web service Messages used by the web service Data types used by the web service Communication protocols used by the web service Service Port (e.g. http://host/svc) Binding (e.g. SOAP) Abstract interface portType operation(s) inMesageoutMessage Port Binding

33 33 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao WSDL Ports The 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

34 34 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao WSDL Messages The 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

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

36 36 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao WSDL Ports – Operation Types WSDL defines four operation types TypeDefinition One-wayThe operation can receive a message but will not return a response Request- response The operation can receive a request and will return a response Solicit- response The operation can send a request and will wait for a response NotificationThe operation can send a message but will not wait for a response

37 37 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao One-Way Operation Input only

38 38 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Request-Response Operation Input and output

39 39 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao WSDL Bindings WSDL bindings ( element) defines the message format and protocol details for a web service Many different bindings are defined: SOAP, HTTP and MIME

40 40 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Binding to SOAP <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />

41 41 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Binding to SOAP The binding 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

42 42 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao 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" />

43 43 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao Binding to SOAP The operation 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

44 44 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao 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

45 45 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao 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

46 46 Fall Semester 2008EEC-681: Distributed Computing SystemsWenbing Zhao References XML: http://java.sun.com/webservices/jaxp/dist/1.1/do cs/tutorial/index.html http://java.sun.com/webservices/jaxp/dist/1.1/do cs/tutorial/index.html SOAP: http://www.w3schools.com/soap/default.asp http://www.w3schools.com/soap/default.asp WSDL and UDDI: http://www.w3schools.com/wsdl/default.asp http://www.w3schools.com/wsdl/default.asp


Download ppt "EEC-681/781 Distributed Computing Systems Lecture 7 Wenbing Zhao (Lecture nodes are based on materials obtained from"

Similar presentations


Ads by Google