Presentation is loading. Please wait.

Presentation is loading. Please wait.

TP2653 Adv Web Programming SOAP and WSDL. SOAP Simple Object Access Protocol – Lightweight XML-based messaging protocol – A protocol for accessing a Web.

Similar presentations


Presentation on theme: "TP2653 Adv Web Programming SOAP and WSDL. SOAP Simple Object Access Protocol – Lightweight XML-based messaging protocol – A protocol for accessing a Web."— Presentation transcript:

1 TP2653 Adv Web Programming SOAP and WSDL

2 SOAP Simple Object Access Protocol – Lightweight XML-based messaging protocol – A protocol for accessing a Web Service – Allows applications to exchange information over HTTP – Platform/language independent – A W3C recommendation (June 2003)

3 Why SOAP? Allowing internet communication between programs Usually applications communicate using RPC (DCOM or CORBA) – causing compatibility and security problems

4 SOAP Building Blocks SOAP message – XML document with: – Envelope element – identifies the XML document as a SOAP message – Header element – contains header information – Body element – contains call/response information – Fault element – contains errors/status information

5 SOAP message - skeleton.........

6 Syntax Rules SOAP message syntax rules: – Must be encoded using XML – Must be using SOAP envelope namespace – Must be using SOAP encoding namespace – Must NOT contain DTD reference – Must NOT contain Processing Instructions

7 SOAP - HTTP protocol HTTP communicates over TCP/IP – HTTP client connects to HTTP server using TCP CLIENT SERVER With connection, client send HTTP request message to server POST /item HTTP/1.1 Host: 189.123.255.239 Content-Type: text/plain Content-Length: 200 After processing, server send HTTP response to client 200 OK Content-Type: text/plain Content-Length: 200

8 SOAP HTTP binding SOAP method – HTTP request/response that complies with SOAP encoding rules – HTTP + XML = SOAP – HTTP POST or HTTP GET HTTP POST – Content-Type – MIME type for message and character encoding – Content-Length – number of bytes in body of request/response

9 SOAP example – a request POST /InStock HTTP/1.1 Host: www.example.org Content-Type: application/soap+xml; charset=utf-8 Content-Length: nnn IBM

10 SOAP example – a response HTTP/1.1 200 OK Content-Type: application/soap+xml; charset=utf-8 Content-Length: nnn 34.5

11 WSDL Web Services Description Language – XML-based to describe Web Services and how to access them – Is an XML file, written in XML format – A W3C recommendation (June 2007)

12 WSDL Structure WSDL document describes a web service using these elements:

13 WSDL document – main structure definition of types........ definition of a message.... definition of a port....... definition of a binding....

14

15 WSDL example <definitions name='Catalog' targetNamespace='http://example.org/catalog' xmlns:tns='http://example.org/catalog' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/' xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/' xmlns='http://schemas.xmlsoap.org/wsdl/'> …

16 WSDL example (cont) … <soap:body use='encoded' namespace='urn:localhost-catalog' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> <soap:body use='encoded' namespace='urn:localhost-catalog' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>

17 SOAP/WSDL + PHP Coding time!

18 SOAP/WSDL + PHP SOAP/WSDL extension in PHP

19 MethodDescription SoapServer->__construct( mixed wsdl [, array options] ) Creates a SoapServer object. The wsdl parameter specifies the URI of the WSDL. SoapServer options such as SOAP version may be specified in the options array. SoapServer->addFunction( mixed functions ) Adds one or more PHP functions that will handle SOAP requests. A single function may be added as a string. More than one function may be added as an array. SoapServer->fault()SoapServer fault indicating an error. SoapServer->getFunctions()Returns a list of functions. SoapServer->handle() Processes a SOAP request, invokes required functions and sends back a response. SoapServer->setClass(string class_name [, mixed args [, mixed...]] ) Sets the class that will handle SOAP requests. Exports all methods from the specified class. The args are used by the default class constructor. SoapHeader->__construct()Creates a SOAP header. SoapClient->__soapCall( string function_name, array arguments [, array options [, mixed input_headers [, array &output_headers]]] ) Invokes a SOAP function. SoapClient->__doRequest()Performs a SOAP request. SoapClient->__getFunctions()Returns a list of SOAP functions. SoapClient->__getTypes()Returns a list of SOAP types.

20 The End


Download ppt "TP2653 Adv Web Programming SOAP and WSDL. SOAP Simple Object Access Protocol – Lightweight XML-based messaging protocol – A protocol for accessing a Web."

Similar presentations


Ads by Google