1 / 29

Simple Object Access Protocol

Simple Object Access Protocol. Why S imple O bject A ccess P rotocol. Light weight replacement for complicated distributed object technology Originally for BizTalk ( Microsoft/UserLand/Developmentor ) Now a W3C standard Based on XML and HTTP. Port vs Web Server. External Application.

hal
Download Presentation

Simple Object Access Protocol

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. Simple Object Access Protocol

  2. Why Simple Object Access Protocol • Light weight replacement for complicated distributed object technology • Originally for BizTalk (Microsoft/UserLand/Developmentor) • Now a W3C standard • Based on XML and HTTP Web Services: SOAP

  3. Port vs Web Server External Application Internal Service External Application Internal Service TCP External Application Internal Service Web Services: SOAP

  4. Port vs Web Server • “XML-RPC” • Port 80? • SOAP is not restricted to port 80 External Application Internal Service Web Server External Application Internal Service XML payload TCP External Application Internal Service Web Services: SOAP

  5. SOAP over HTTP • Request example POST /Temperature HTTP/1.1 Host: www.weather.com Content-Type: text/xml Content-Length: <whatever> SOAPAction: “urn:StockQuote#GetQuote” <s:Envelope xmlns:s=“http://www.w3.org/2001/06/soap-envelope"> <s:Body> … … </s:Body> </s:Envelope> HTTP Header Soap Extensions XML Payload (SOAP request) Web Services: SOAP

  6. SOAP over HTTP HTTP/1.1 200 OK Content-Type: text/xml Content-Length: <whatever> <s:Envelope xmlns:s=“http://www.w3.org/2001/06/soap-envelope"> <s:Body> … … </s:Body> </s:Envelope> • Response example HTTP Header XML Payload (SOAP response) Web Services: SOAP

  7. SOAP Example: Request <soap:Envelope> <soap:Body> <xmlns:m= "http://www.amzn.org/books" />    <m:GetBookPrice> <m:BookName>Fast Food Nation</m:BookName>       </m:GetBookPrice> </soap:Body> </soap:Envelope> Web Services: SOAP

  8. SOAP Example: Response <soap:Envelope> <soap:Body> <xmlns:m="http://www.amzn.org/books" /> <m:GetBookPriceResponse> <m:Price>34.5</m:Price> </m:GetBookPriceResponse> </soap:Body> </soap:Envelope> Web Services: SOAP

  9. SOAP Example: Error <soap:Fault> <faultcode>0x800700E</faultcode> <faulstring>Unknown book</faultstring> </soap:Fault> Web Services: SOAP

  10. SOAP Message • A SOAP message is contained within an XML “envelope”, complete with a Header and Body SOAP Envelope SOAP Header (optional) SOAP Body “payload” Web Services: SOAP

  11. SOAP Message with Binary Attachments • A SOAP message can also contain binary attachments using MIME encoding MIME Header MIME Boundary Root Body Part SOAP Envelope SOAP Header (optional) SOAP Body “payload” MIME Boundary Body Part Attachment Web Services: SOAP

  12. Envelope contains Header Body Header is optional Out-of-band information such as… Authentication information Message routes Logging Transaction flow Body contains XML body of RPC call SOAP Structure SOAP Envelope SOAP Header Header Block . . . Header Block SOAP Body Body Block . . . Body Block Web Services: SOAP

  13. SOAP Example <?xml version="1.0" encoding="UTF-8" ?> <env:Envelopexmlns:env="http://www.w3.org/2001/09/soap-envelope"> <env:Header> <n:alertcontrol xmlns:n="http://example.org/alertcontrol"> <n:priority>1</n:priority> <n:expires>2001-06-22T14:00:00-05:00</n:expires> </n:alertcontrol> </env:Header> <env:Body> <m:alert xmlns:m="http://example.org/alert"> <m:msg>Pick up Mary at school at 2pm</m:msg> </m:alert> </env:Body> </env:Envelope> Web Services: SOAP

  14. XML Messaging in SOAP • EDI: Electronic Document Interchange • SOAP with EDI: XML documents“Document style SOAP” • RPC: distributed computing, web services • “RPC-style” SOAP: parameters and return values Web Services: SOAP

  15. Purchase Order in Document-Style SOAP <s:Envelope xmlns:s=“http://www.w3.org/2001/06/soap-envelope”> <s:Header> <m:transaction xmlns:m=“soap-transaction” s:mustUnderstand=“true”> <transactionID>1234</transactionID> </transaction> </s:Header> <s:Body> <n:purchaseOrder xmlns:n=“urn:OrderService”> <from><person>Christopher Robin</person> <dept>Accounting</dept> </from> <to><person>Pooh Bear</person> <dept>Honey></dept> </to> <order><quantity>1</quantity> <item>Pooh Stick</item> </order> </n:purchaseOrder> </s:Body> </s:Envelope> Web Services: SOAP

  16. RPC Messages • Typically two messages Request Message SOAP Client SOAP Server Response Message Web Services: SOAP

  17. An RPC-style SOAP Message public Float getQuote (String symbol); <s:Envelope xmlns:s=“http://www.w3.org/2001/06/soap-envelope”> <s:Header> <m:transaction xmlns:m=“soap-transaction” s:mustUnderstand=“true”> <transactionID>1234</transactionID> </m:transaction> </s:Header> <s:Body> <n:getQuote xmlns:n=“urn:QuoteService”> <symbol xsi:type=“xsd:string”> IBM </symbol> </n:getQuote> </s:Body> </s:Envelope> Web Services: SOAP

  18. SOAP Response <s:Envelope xmlns:s=http://www.w3.org/2001/06/soap-envelope> <s:Body> <n:getQuoteResponse xmnls:n=“urn:QuoteService”> <value xsi:type=“xsd:float”> 98.06 </value> </n:getQuoteResponse> </s:Body> </s:Envelope> Web Services: SOAP

  19. SOAP Faults <s:Envelope xmlns:s=“http://www.w3.org/2001/06/soap-envelope” > <s:Body> <s:Fault> <faultcode>Client.Authentication</faultcode> <faultstring>Invalid credentials</faultstring> <faultactor>http://acme.com/</faultactor> <details> <!-- application specific details></details> </s:Fault> </s:Body> </s:Envelope> Web Services: SOAP

  20. Standard SOAP Fault Codes • Version Mismatch • MustUnderstand: specify which header blocks were not understood • Server: error can’t be directly linked to the processing of the message • Client: there is a problem in the message (e.g. invalid authentication credentials) Web Services: SOAP

  21. SOAP Data Encoding • One possible method of serializing data and encode them into XML • Section 5 of the SOAP standard • General rules Web Services: SOAP

  22. Compound Values • A compound value represents a combination of two or more accessors grouped as children of a single accessor • Each accessor has a different name (structs) • <name> • <firstname>Joe</firstname> • <lastname>Smith</lastname> • </name> Web Services: SOAP

  23. Arrays • An array is a compound value in which the accessors have the same name <people> <person name=‘joe smith’ /> <person name=‘john doe’ /> </people> Web Services: SOAP

  24. Multi-Referenced Accessor <people> <person name=‘joe smith’> <address href=‘#address-1’> </person> <person name=‘john doe’> <address href=‘#address-1’> </person> </people> <address id=‘address-1’> <street>111 First Street</street> <city>New York</city> <state>New York</state> </address> Web Services: SOAP

  25. Express the Data Type of an Accessor • Use the xsi:type attribute on each accessor, explicitly referencing the data type according to the XML Schema specification: <person><name xsi:type=“xsd:string”>John Doe</name> • Reference an XML Schema document that defines the exact data type of a particular element within its definition: <person xmlns=“personschema.xsd”> <name>John Doe</name></person> • Reference some other type of schema document that defines the data type of a particular element within its definition: <person xmlns=“urn:some_namespace”> <name>John Doe</name> Web Services: SOAP

  26. SOAP Data Types • Two alternate syntaxes for expressing instances of data types • Anonymous accessor: <SOAP-ENC:int>36</SOAP-ENC:int> • Anonymous because its name is its type rather than a meaningful id for the value • Named accessor: <value xsi:type=“xsd:int”>36</value> Web Services: SOAP

  27. Arrays • Arrays int a[3] = {1, 2, 3}; b = Add([in]a); <m:Add xmlns:m=“http://a.com/Calculator” xmlns:SOAP-ENC= "http://schemas.xmlsoap.org/soap/encoding/”> <a SOAP-ENC:arrayType=“xsd:int[3]”> <SOAP-ENC:int>1</SOAP-ENC:int> <SOAP-ENC:int>2</SOAP-ENC:int> <SOAP-ENC:int>3</SOAP-ENC:int> </a> </m:Add> Web Services: SOAP

  28. Values and References • By value : Add([in] int a, [in] int b); • By reference : Square([in, out] int &a); <m:Add xmlns:m=“http://a.com/Calculator”> <a xsi:type=“integer”>3</a> <b xsi:type=“integer”>4</b> </m:Add> <m:Add xmlns:m=“http://a.com/Calculator”> <a href=“#arg” /> </m:Add> <a id=“arg” xsi:type=“integer”>8</a> Web Services: SOAP

  29. Summary • SOAP protocol: an XML encoding scheme to exchange information between web processes: • Document style: XML documents • RPC style: packing parameters in XML format • Typically SOAP/HTTP, others are possible • Low level in terms of process/service modeling Web Services: SOAP

More Related