1 / 33

Web Services: SOAP

Web Services: SOAP. SOAP. SOAP ir standarts Web servisu saziņošanas protokols Oriģināli SOAP nozīmēja S imple O bject A ccess P rotocol vēlāk arī S ervice O riented A rchitecture P rotocol bet sākot ar versiju 1.2 tas ir vienkārši SOAP. Vēsture un versijas.

dakota
Download Presentation

Web Services: SOAP

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. Web Services: SOAP

  2. SOAP • SOAP ir standarts Web servisu saziņošanas protokols • Oriģināli SOAP nozīmēja • Simple Object Access Protocol vēlāk arī • Service Oriented Architecture Protocol bet sākot ar versiju 1.2 tas ir vienkārši SOAP

  3. Vēsture un versijas • SOAP 1998. gadā izstrādāja Dave Winer, Don Box, Bob Atkinson un Mohsen Al-Ghosein • SOAP 1.1 – W3C ierosinājums 2000.gada maijā • J2EE1.4 standarts • SOAP 1.2 – W3C rekomendācija sākot ar 2003.gada jūniju • Java EE 5 standarts

  4. Kas ir SOAP? • SOAP is a communication protocol • SOAP is for communication between applications • SOAP is a format for sending messages • SOAP is designed to communicate via Internet • SOAP is platform independent • SOAP is language independent • SOAP is based on XML • SOAP is simple and extensible • SOAP allows you to get around firewalls • SOAP is developed as a W3C standard

  5. Kas SOAP nav? • SOAP nav komponentu modelis • Tas neaizvietos objektus un komponentus, piemērām EJB, JavaBeans • SOAP nav programmēšanas valoda • Tas neaizvietos Java valodu • SOAP nav risinājums visiem uzdevumiem • Tas neaizvietos citas dalītas apstrādes tehnoloģijas, tādās kā, piemērām, RMI

  6. Kāpēc SOAP? • Izstrādājot lietojumprogrammas ir svarīgi dot iespēju programmām sazināties pa Internetu • Viens sazināšanas veids ir RPC (Remote Procedure Call), bet HTTP nav īsti piemērots šīm variantam • SOAP bija izveidots, lai nodrošināt iespēju sazināties pa HTTP (kaut gan var tikt izmantots arī cits protokols, piemēram SMTP)

  7. SOAP over HTTP, SMTP, and Raw TCP/IP A SOAP XML document instance, which is called a SOAP message,is usually carried as the payload of some other network protocol

  8. One-Way versus Request/Response • Web services can use One-Way messaging or Request/Response messaging

  9. Ko SOAP definē? • Message Envelope • Encoding Rules • RPC Convention • Binding with underlying protocols

  10. SOAP Message • SOAP messageis made of • SOAP Envelope (in XML) • Zero or more attachments • Zero or more "underlying protocol" header fields • SOAP Envelope is composed of • SOAP body • Main content of the message • Zero or more SOAP header blocks • Metadata • Data aimed at intermediaries • Can also contain application data for ultimate receiver

  11. SOAP Message Format

  12. HTTP Request HTTP Body XML Syntax SOAP Envelope SOAP Body SOAP Body Block Textual Integer 0x0b66 SOAP in HTTP Request Sender Receiver

  13. SOAP Message Structure • A SOAP message is analogous to an envelope used in traditional postal service • A SOAP message is a kind of XML document • SOAP has its own XML schema, namespaces, and processing rules <?xml version="1.0" encoding="UTF-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header> <!-- Header blocks go here --> </soap:Header> <soap:Body> <!-- Application data goes here --> </soap:Body> </soap:Envelope>

  14. SOAP Message Structure • A SOAP message may have a single Body element preceded, optionally, by one Headerelement • The Envelope element cannot contain any other children! • The Header element contains information about the message: • security credentials • transaction IDs • routing instructions • debugging information • payment tokens

  15. Example: SOAP Header <?xml version="1.0" encoding="UTF-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mi="http://www.Monson-Haefel.com/message-id"> <soap:Header> <mi:message-id> 11d1def534ea:b1c5fa:f3bfb4dcd7:-8000 </mi:message-id> </soap:Header> <soap:Body> <!-- Application-specific data goes here --> </soap:Body> </soap:Envelope>

  16. SOAP Namespaces • XML namespaces play an important role in SOAP messages • Examples of namespace prefixes:

  17. Example: SOAP Namespaces <?xml version="1.0" encoding="UTF-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sec="http://schemas.xmlsoap.org/soap/security/2000-12" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:mi="http://www.Monson-Haefel.com/jwsbook/message-id"> <soap:Header> <mi:message-id>11d1def534ea:b1c5fa:f3bfb4dcd7:-8000</mi:message-id> <sec:Signature>...</sec:Signature> </soap:Header> <soap:Body sec:id="Body"> <po:purchaseOrder orderDate="2003-09-22" xmlns:po="http://www.Monson-Haefel.com/jwsbook/PO" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> ... </po:purchaseOrder> </soap:Body> </soap:Envelope>

  18. SOAP Message Path • Initial sender creates message • Ultimate receiverexecutes main operation • Intermediaries perform additional processing

  19. Initial sender Security intermediary Final receiver SOAP Nodes • The applications along the message path are also called SOAP nodes • Example: • security node authenticates users and verifies message integrity • SOAP message Header blocks are intended to be processed in general by intermediary nodes

  20. Roles and Targeting • Header blocks are targeted to node via "role" attribute (URI) • Role is either address of a node or role name • E.g. this security intermediary (address) • E.g. any security intermediary (role name) • Example <ns:myHeaderBlock role="…/logging" /> • The Body is always targeted to ultimate receiver

  21. Roles and Targeting • SOAP defines three special roles: • none • next • ultimateReceiver • The "mustUnderstand"attribute • If set to “true”, the node must know how to process the header • If a node doesn't understand a mandatory header block, it must generate a SOAP fault

  22. Example: Headers with Roles <?xml version='1.0' ?> <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"> <env:Header> <m:reservation xmlns:m="…" env:role= "http://www.w3.org/2003/05/soap-envelope/role/next" env:mustUnderstand="true"> <m:reference>uuid:093a2da1-q345-739r-ba5d-pqff98fe8j7d </m:reference> <m:dateAndTime>2001-11-29T13:20:00.000-05:00</m:dateAndTime> </m:reservation> <n:passenger xmlns:n=“…" env:role=" http://www.w3.org/2003/05/soap-envelope/role/next" env:mustUnderstand="true"> <n:name>Åke Jógvan Øyvind</n:name> </n:passenger> </env:Header>

  23. Intermediary Node Algorithm • Receive message • Determine roles played • Verify all mandatory blocks targeted to node are understood • Process appropriate header blocks • Processing possibly produces a fault • Remove processed headers • Add new headers if necessary • Forward message to next node

  24. Ultimate Receiver Algorithm • Receive message • Process appropriate header blocks • Processing possibly produces a fault • Process all body blocks • Processing possibly produces a fault

  25. SOAP Messaging Modes • SOAP supports four modes of messaging • RPC/Literal • Document/Literal • RPC/Encoded • Document/Encoded • However, RPC/Encoded and Document/Encoded modes are explicitly prohibited

  26. Document/Literal Mode • In the Document/Literal mode of messaging, a SOAP Body element contains an XML document fragment • A well-formed XML element that contains arbitrary application data (text and other elements) that belongs to some XML schema and namespace

  27. Example: Document/Literal Body <soap:Body> <po:purchaseOrder orderDate="2003-09-22" xmlns:po=“http://www.Monson-Haefel.com/jwsbook/PO"> <po:accountName>Amazon.com</po:accountName> <po:accountNumber>923</po:accountNumber> ... <po:book> <po:title>J2EE Web Services</po:title> <po:quantity>300</po:quantity> <po:wholesale-price>24.99</po:wholesale-price> </po:book> </po:purchaseOrder> </soap:Body>

  28. RPC/Literal Mode • The RPC/Literal mode of messaging enables SOAP messages to model calls to procedures or method calls with parameters and return values • The contents of the Body are always formatted as a struct • In many cases is used to expose traditional components (servlet, EJB, RMI) as Web services

  29. Example: RPC/Literal public interface BookQuote extends java.rmi.Remote { public float getBookPrice(String ISBN) throws RemoteException, InvalidISBNException; } <soap:Envelopexmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mh="http://www.Monson-Haefel.com/jwsbook/BookQuote"> <soap:Body> <mh:getBookPrice><isbn>0321146182</isbn></mh:getBookPrice> </soap:Body> </soap:Envelope> <soap:Envelopexmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mh="http://www.Monson-Haefel.com/jwsbook/BookQuote" > <soap:Body> <mh:getBookPriceResponse><result>24.99</result> </mh:getBookPriceResponse> </soap:Body> </soap:Envelope>

  30. SOAP Faults • SOAP fault messages are the mechanism by which SOAP applications report errors to nodes earlier in the message path • SOAP faults are returned to the receiver's immediate sender only • Fault element information items • faultcode • Client, Server, VersionMismatch, MustUnderstand • faultstring • faultactor • detail

  31. Example: SOAP Fault <soap:Fault> <faultcode>soap:Client</faultcode> <faultstring> The ISBN value contains invalid characters </faultstring> <faultactor>http://www.xyzcorp.com</faultactor> <detail> <mh:InvalidIsbnFaultDetail> <offending-value>19318224-D</offending-value> <conformance-rules> The first nine characters must be digits. The last character may be a digit or the letter 'X'. Case is not important. </conformance-rules> </mh:InvalidIsbnFaultDetail> </detail> </soap:Fault>

  32. SOAP over HTTP • SOAP messages sent over HTTP are placed in the payload of an HTTP request or response POST /jwsbook/BookQuote HTTP/1.1 Host: www.Monson-Haefel.com Content-Type: text/xml; charset="utf-8" Content-Length: 295 SOAPAction="" <?xml version="1.0" encoding="UTF-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mh="http://www.Monson-Haefel.com/jwsbook/BookQuote"> <soap:Body> <mh:getBookPrice> <isbn>0321146182</isbn> </mh:getBookPrice> </soap:Body> </soap:Envelope>

  33. References • SOAP Tutorial (W3C Schools)http://www.w3schools.com/soap/default.asp • SOAP-1.2 Primerhttp://www.w3.org/TR/soap12-part0/ • SOAP Version 1.2 W3C Specificationhttp://www.w3.org/TR/soap12-part1/ • Book “J2EE Web Services” by Richard Monson-Haefel http://www.amazon.ca/J2EE-Web-Services-Richard-Monson-Haefel/dp/0321146182

More Related