Presentation is loading. Please wait.

Presentation is loading. Please wait.

SOAP, Web Service, WSDL Week 14 Web site:

Similar presentations


Presentation on theme: "SOAP, Web Service, WSDL Week 14 Web site:"— Presentation transcript:

1 SOAP, Web Service, WSDL Week 14 Web site: http://fog.ccsf.edu/~hyip

2 Usage of XML Ajax Web Service, WSDL SOAP

3 Web Service A Web Service is a set of functions that can be accessed and executed over a network. While generic in its definition, a Web Service usually refers to the exchange of XML messages using the SOAP framework. SOAP’s core functionality is to support this exchange of XML messages from one application to another. SOAP is a lightweight protocol because, for the most part, a SOAP message is basically an XML file in a SOAP wrapper. And, this wrapper, often referred to as the SOAP envelope, adds very little overhead to the messaging process. The exchange of SOAP messages is most frequently done over the Internet via HTTP. A client application sends a SOAP message as an HTTP request, and the server sends back its SOAP message as an HTTP response. Because the SOAP message exchange works using HTTP, it allows for easier communication between computers on different networks. This is one of the biggest advantages of using SOAP over other remote communication frameworks.

4 Sample of Web Service Web Service – Hello  Function sayHello  Function sayHelloToWorld …

5 Simple Object Access Protocol (SOAP) SOAP version 1.2 is an XML-based messaging framework. SOAP supports server-to-server communication. Specifically, it allows for platform- and language-independent communication between different applications, typically running on different servers.

6 SOAP Message Schema The SOAP framework is based on the XML language, which means that all the rules about writing XML documents apply to SOAP messages. The root element of a SOAP message is the Envelope element. It must declare the SOAP namespace, which defines the elements and attributes of a SOAP message. A SOAP message has an optional Header element which, if present, must be the first immediate child of the Envelope element. It allows application-specific communication between the client and the server, beyond the actual SOAP message itself. The Body element is a required child element of the Envelope element and contains the actual SOAP message content. In a request message, the Body element’s children correspond to the operation being called, and its grandchildren correspond to the operation’s parameters. In a response message, the word “Response” is typically appended to the Body element’s children (the operation elements) and its grandchildren are the operation’s result values.

7 SOAP request (request.xml) This SOAP request message is calling the procedure sayHello and passing the name parameter with the value “Kevin”. Kevin

8 SOAP response (response.xml) This SOAP message is the response to the request message above. It is returning the result of the sayHello procedure, using the sayHelloResponse element. <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> Hello Kevin, How are you?

9 The 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: 189.123.255.239 Content-Type: text/plain Content-Length: 200

10 The HTTP Protocol (continue…) 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: 200 OK Content-Type: text/plain Content-Length: 200

11 SOAP Binding The SOAP specification defines the structure of the SOAP messages, not how they are exchanged. This gap is filled by what is called "SOAP Bindings". SOAP bindings are mechanisms which allow SOAP messages to be effectively exchanged using a transport protocol. Most SOAP implementations provide bindings for common transport protocols, such as HTTP or SMTP. HTTP is synchronous and widely used. A SOAP HTTP request specifies at least two HTTP headers: Content-Type and Content- Length. SMTP is asynchronous and is used in last resort or particular cases. Java implementations of SOAP usually provide a specific binding for the JMS (Java Messaging System) protocol.

12 A SOAP example with HTTP In the example below, a sayHello request is sent to a server. The request has a Name parameter, and a sayHelloResult parameter that will be returned in the response. The namespace for the function is defined in "http://www.xyz.com/ns/hello".

13 A SOAP request POST /Hello HTTP/1.1 Host: www.example.org Content-Type: application/soap+xml; charset=utf-8 Content-Length: nnn Kevin

14 The SOAP response HTTP/1.1 200 OK Content-Type: application/soap+xml; charset=utf-8 Content-Length: nnn <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> Hello Kevin, How are you?

15 Web Services Description Language (WSDL) WSDL is an XML language for describing how to interface with Web Services. Where SOAP provides the message exchange framework for a Web Service, WSDL documents the messages that can be sent. WSDL is not needed for the exchange of Web Service messages – this can happen using SOAP exclusively. However, with WSDL, requesting applications are given technical information abut the Web Service which supports an easier, more automated, and less error prone exchange.

16 WSDL Schema A WSDL document is an XML document, and its root element is definitions. The definitions elements has five major child elements (in sequence): types, message, portType, binding, and service. The center hub of them all is the portType element. It describes the available operations and the messages each expects. It is the equivalent of a description of the application’s library, and each operation contains the equivalent of a list of specific function calls. The types and message elements work hand in hand. The message element identifies the messages each operation expects, and the parameters each message will contain. These parameters reference the elements defined for your Web Service, and their definitions are found in the types element. The binding element defines the transport protocol of the SOAP message exchange (which is typically done via HTTP, but can be done via SMTP, FTP, or other transport protocols). Then, for each named operation, you define how the messages appear inside the SOAP body element. Finally, the service element puts together the pieces of the Web service by connecting the portType with the binding. And it identifies the public URI of the Web Service itself.

17 WSDL Document data type definitions........ definition of the data being communicated.... set of operations...... protocol and data format specification....

18 WSDL Sample

19 WSDL Binding to SOAP

20 References XML: Visual QuickStart Guide, 2 nd Edition, by Kevin Howard Goldberg, Peachpit Press, ISBN 0321559673 http://www.w3schools.com/


Download ppt "SOAP, Web Service, WSDL Week 14 Web site:"

Similar presentations


Ads by Google