Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Web Services: SOAP. 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."— 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ā J2EE 1.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 message is 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 SOAP in HTTP Request SenderReceiver HTTP Request HTTP Body XML Syntax SOAP Envelope SOAP Body SOAP Body Block Textual Integer 0x0b66

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

14 SOAP Message Structure A SOAP message may have a single Body element preceded, optionally, by one Header element 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 <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mi="http://www.Monson-Haefel.com/message-id"> 11d1def534ea:b1c5fa:f3bfb4dcd7:-8000

16 SOAP Namespaces XML namespaces play an important role in SOAP messages Examples of namespace prefixes: PrefixNamespace soap"http://schemas.xmlsoap.org/soap/envelope/" xsi"http://www.w3.org/2001/XMLSchema-instance" xsd"http://www.w3.org/2001/XMLSchema" soapenc"http://schemas.xmlsoap.org/soap/encoding/" wsdl"http://schemas.xmlsoap.org/wsdl/" soapbind"http://schemas.xmlsoap.org/wsdl/soap/" wsi"http://ws-i.org/schemas/conformanceClaim/"

17 Example: SOAP Namespaces <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"> 11d1def534ea:b1c5fa:f3bfb4dcd7:-8000... <po:purchaseOrder orderDate="2003-09-22" xmlns:po="http://www.Monson-Haefel.com/jwsbook/PO" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">...

18 SOAP Message Path Initial sender creates message Ultimate receiver executes main operation Intermediaries perform additional processing

19 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 Initial senderFinal receiverSecurity intermediary

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 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 <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"> <m:reservation xmlns:m="…" env:role= "http://www.w3.org/2003/05/soap-envelope/role/next" env:mustUnderstand="true"> uuid:093a2da1-q345-739r-ba5d-pqff98fe8j7d 2001-11-29T13:20:00.000-05:00 <n:passenger xmlns:n=“…" env:role=" http://www.w3.org/2003/05/soap-envelope/role/next" env:mustUnderstand="true"> Åke Jógvan Øyvind

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 <po:purchaseOrder orderDate="2003-09-22" xmlns:po=“http://www.Monson-Haefel.com/jwsbook/PO"> Amazon.com 923... J2EE Web Services 300 24.99

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:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mh="http://www.Monson-Haefel.com/jwsbook/BookQuote"> 0321146182 <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mh="http://www.Monson-Haefel.com/jwsbook/BookQuote" > 24.99

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:Client The ISBN value contains invalid characters http://www.xyzcorp.com 19318224-D The first nine characters must be digits. The last character may be a digit or the letter 'X'. Case is not important.

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="" <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mh="http://www.Monson-Haefel.com/jwsbook/BookQuote"> 0321146182

33 References SOAP Tutorial (W3C Schools) http://www.w3schools.com/soap/default.asp http://www.w3schools.com/soap/default.asp SOAP-1.2 Primer http://www.w3.org/TR/soap12-part0/ http://www.w3.org/TR/soap12-part0/ SOAP Version 1.2 W3C Specification http://www.w3.org/TR/soap12-part1/ http://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


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

Similar presentations


Ads by Google