190 likes | 320 Views
Simple Object Access Protocol. CS409 Application Services. Even Semester 2007. Web Service Requirements. An industry standard web service : Provide a service description, at least, a WSDL document. Capable of transporting XML documents using SOAP over HTTP.
E N D
Simple Object Access Protocol CS409 Application Services Even Semester 2007
Web Service Requirements • An industry standard web service : • Provide a service description, at least, a WSDL document. • Capable of transporting XML documents using SOAP over HTTP. • Be registered with a discovery agent. • Able to act as both the requestor and provider of a service (optional). • e.g: provider asking for status information.
SOAP Definition • A standard to access web services. • Establishes standard message format that consists of XML document. • Allows the provider and receiver of XML document to effectively communicate over the network. • Able to process document and RPC centric data, as well as attachments.
Data Business Rules Business Rules Data Service Interface Service Interface Presentation Presentation SOAP message SOAP message Role of SOAP Application B Application A Fig 1. SOAP Standpoint
SOAP Messaging Framework • SOAP node: • A processing logic responsible for processing tasks on SOAP messages. • Also known as SOAP server, SOAP listener, SOAP routers. • SOAP node types: • Senders. • Receiver. • Intermediary.
SOAP Node Types Message path SOAP Sender Service Requestor SOAP Intermediary Intermediary Service SOAP Receiver Service Provider SOAP Intermediary Intermediary Service Initial Sender Ultimate Receiver Fig 2. SOAP Node
Header BlockBlock. . . Body BlockBlock. . . SOAP Structure Unit of communication Envelope Attributes of the communication Message of communication: method name with arguments or document Fig 3. SOAP Message Structure
SOAP Envelope • Marks the start and the end of SOAP message. • It is the container/packaging of the message. • Example: <?xml version=“1.0” encoding=“UTF-8”> <SOAP-ENV:Envelope xmlns:SOAP-ENV=“http://www.w3.org/2003/05/soap-envelope” > <SOAP-ENV:Header> . . . </SOAP-ENV:Header> <SOAP-ENV:Body> . . . </SOAP-ENV:Body> </SOAP-ENV:Envelope>
SOAP Header • Header is optional. • Contain the attributes of the message, any application-defined information associated with the message. • Can be extended to include additional features and functionalities.
SOAP Header (2) <SOAP-ENV:Header> <t:Transaction xmlsns:t=“www.xmlbus.com” SOAP-ENV:mustUnderstand=“1”> <!-- the receiving node must support Transaction or generate an error code or SOAP fault if it does not --> </t:Transaction> <proc:processed-by> <!-- Information about intermediary processing nodes goes here --> <node> <time-in-millis>1013694680000</time-in-millis> <identity>http://www.doddystore.com/sales</identity> </node> </proc:processed-by> <mi:message-id SOAP-ENV:acor=“http://www.doddystore.com/logger” > <!-- The id element of the message --> 4ryiuyr93247:huh434:f43yr7f:-8000 </mi:message-id> </SOAP-ENV:Header>
SOAP Body • The most important and required part. • Consists of: • The information we want to exchange with web service. • Fault message to send to previous node when an error occur. • Should be processed only by the ultimate receiver.
SOAP Body (2) • Document/Literal centric example <SOAP-ENV:Body> <po:purchaseOrder oderDate=“2006-02-28” xmlns:po=“http://www.doddystore.com/PO”> <po:accountName>amazon.com</po:accountName> <po:accountNumber>8899</po:accountNumber> <po:book> <po:title>CS409 Application Services</po:title> <po:quantity>89</po:quantity> <po:price>24.99</po:price> </po:book> </po:purchaseOrder> </SOAP-ENV:Body>
SOAP Body (3) • RPC/Literal centric example <SOAP-ENV:Envelope xmlns:SOAP-ENV=“http://www.w3.org/2003/05/soap-envelope/” xmlns:mh=“http://www.doddystore.com/BookQuote/” > <SOAP-ENV:Body> <!-- This is a sample request message --> <mh:getBookPrice> <isbn>032111678</isbn> </mh:getBookPrice> <SOAP-ENV:Body> </SOAP-ENV:Envelope> <SOAP-ENV:Envelope xmlns:SOAP-ENV=“http://www.w3.org/2003/05/soap-envelope/” xmlns:mh=“http://www.doddystore.com/BookQuote/” > <SOAP-ENV:Body> <!-- This is a sample response message --> <mh:getBookPriceResponse> <result>24.99</result> </mh:getBookPriceResponse> <SOAP-ENV:Body> </SOAP-ENV:Envelope>
SOAP Body (4) • SOAP fault: • <faultcode>, can be standard code (Client, Server, VersionMismatch, MustUnderstand) or non-standard fault codes. • <faultstring>, explanation about the fault. • <faultactor>, URI identifying the address of SOAP processor generates the fault. • <detail>, application specific information about the fault.
SOAP Body (5) • SOAP fault sample: <SOAP-ENV:Body> <SOAP-ENV:Fault> <faultcode>SOAP-ENV:Client<faultcode> <faultstring>The ISBN code contains an invalid characters</faultstring> <faultactor>http://www.doddystore.com/priceProcessor/</faultactor> <detail> <mh:ISBNFaultDetail> <offending-value>12345</offending-value> <conformance-rules> ISBN cannot contains special characters such as %, &, or #. </conformance-rules> </mh:ISBNFaultDetail> </detail> <SOAP-ENV:Fault> <SOAP-ENV:Body>
Sending Binary Data • How to send large blob binary data with web service? • XML can’t directly encode 8-bit binary data. • Workaround: • Use XML schema type base64binary and encode the data as base64 text inside the XML. • Use SOAP with attachment. • DIME = Direct Internet Message Encapsulation by Microsoft and IBM (not widely supported).
Sending Binary Data (2) • Sample using base64 text: <SOAP-ENV:Envelope xmlns:SOAP-ENV=“http://www.w3.org/2003/05/soap-envelope/” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” > <SOAP-ENV:Body> <submitClaim> <accountNumber>Acct001</accountNumber> <eventType>Accident</eventType> <image imageType=“jpg” xsi:type=“base64binary”> 4f3e9 ... <!-- The rest of encoded image goes here --> </image> </submitClaim> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
Sending Binary Data (3) • Sample using attachment: MIME-Version: 1.0 Content-Type: Multipart/Related; boundary=MIME_boundary; type=text/xml; start="<claim061400a.xml@claiming-it.com>" --MIME_boundary Content-Type: text/xml; charset=UTF-8 Content-Transfer-Encoding: 8bit Content-ID: <claim061400a.xml@claiming-it.com> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Body> <theSignedForm href="cid:claim061400a.tiff@claiming-it.com"/> </SOAP-ENV:Body> </SOAP-ENV:Envelope> --MIME_boundary Content-Type: image/tiff Content-Transfer-Encoding: binary Content-ID: <claim061400a.tiff@claiming-it.com> ...binary TIFF image... --MIME_boundary--
Thank You Doddy Lukito dlukito@infinitechnology.com dlukito@alumni.carnegiemellon.edu