1 / 20

TP2653 Adv Web Programming

TP2653 Adv Web Programming. SOAP and WSDL. 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). Why SOAP?.

onawa
Download Presentation

TP2653 Adv Web Programming

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. 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 <?xml version="1.0"?><soap:Envelopexmlns: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>

  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 With connection, client send HTTP request message to server POST /item HTTP/1.1Host: 189.123.255.239Content-Type: text/plainContent-Length: 200 CLIENT SERVER After processing, server send HTTP response to client 200 OKContent-Type: text/plainContent-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.1Host: www.example.orgContent-Type: application/soap+xml; charset=utf-8Content-Length: nnn<?xml version="1.0"?><soap:Envelopexmlns:soap="http://www.w3.org/2001/12/soap-envelope"soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"><soap:Bodyxmlns:m="http://www.example.org/stock">  <m:GetStockPrice>    <m:StockName>IBM</m:StockName>  </m:GetStockPrice></soap:Body></soap:Envelope>

  10. SOAP example – a response HTTP/1.1 200 OKContent-Type: application/soap+xml; charset=utf-8Content-Length: nnn<?xml version="1.0"?><soap:Envelopexmlns:soap="http://www.w3.org/2001/12/soap-envelope"soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"><soap:Bodyxmlns:m="http://www.example.org/stock">  <m:GetStockPriceResponse>    <m:Price>34.5</m:Price>  </m:GetStockPriceResponse></soap:Body></soap:Envelope>

  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 <definitions> <types>  definition of types........ </types> <message>  definition of a message.... </message> <portType>  definition of a port....... </portType> <binding>  definition of a binding.... </binding></definitions>

  14. WSDL example <?xml version ='1.0' encoding ='UTF-8' ?> <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/'> <message name='getCatalogRequest'> <part name='catalogId' type='xsd:string'/> </message> <message name='getCatalogResponse'> <part name='Result' type='xsd:string'/> </message> <portType name='CatalogPortType'> <operation name='getCatalogEntry'> <input message='tns:getCatalogRequest'/> <output message='tns:getCatalogResponse'/> </operation> </portType> …

  15. WSDL example (cont) … <binding name='CatalogBinding' type='tns:CatalogPortType'> <soap:binding style='rpc‘ transport='http://schemas.xmlsoap.org/soap/http’ /> <operation name='getCatalogEntry'> <soap:operationsoapAction='urn:localhost-catalog#getCatalogEntry‘ /> <input> <soap:body use='encoded' namespace='urn:localhost-catalog' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> </input> <output> <soap:body use='encoded' namespace='urn:localhost-catalog' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> </output> </operation> </binding> <service name='CatalogService'> <port name='CatalogPort' binding='CatalogBinding'> <soap:address location='http://www.ftsm.ukm.my/azraai/webservice/soap-server.php'/> </port> </service> </definitions>

  16. Coding time! SOAP/WSDL + PHP

  17. SOAP/WSDL + PHP • SOAP/WSDL extension in PHP

  18. The End

More Related