Presentation is loading. Please wait.

Presentation is loading. Please wait.

SOAP Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.

Similar presentations


Presentation on theme: "SOAP Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University."— Presentation transcript:

1 SOAP Kanda Runapongsa (krunapon@kku.ac.th)krunapon@kku.ac.th Dept. of Computer Engineering Khon Kaen University

2 168493: XML and Web Services (II/2546) 2 Web Services Interaction Diagram Request WSDL location UDDI Registry 1 Download WSDL WSDL Send SOAP messages With XML documents Web Services 2 3

3 168493: XML and Web Services (II/2546) 3 Why Do We Need SOAP? An acceptable standard for routing and packaging XML data exchanged between two applications on a network No need to define our own networking, addressing, and routing protocols

4 168493: XML and Web Services (II/2546) 4 What is SOAP? Simple Object Access Protocol It defines a standard packaging format for transmitting XML data between applications on a network It is not specific to any programming language, product, or hardware platform

5 168493: XML and Web Services (II/2546) 5 What is SOAP? SOAP is not a programming language or a business application component for building business applications SOAP is intended for use as a portable communication protocol to deliver SOAP messages, which have to be created and processed by an application

6 168493: XML and Web Services (II/2546) 6 A SOAP Message A SOAP message is just an XML document The message might be sent from one application to another to synchronize contact information on two different systems SOAP takes advantages of XML namespaces and XML schemas

7 168493: XML and Web Services (II/2546) 7 Anatomy of a SOAP Message The structural format of a SOAP message contains the following elements Envelope Header (optional) Body Attachments (optional)

8 168493: XML and Web Services (II/2546) 8 SOAP Envelope The SOAP envelope is the primary container of a SOAP message’s structure It is the mandatory element of a SOAP message It is represented as the root element of the message as Envelope

9 168493: XML and Web Services (II/2546) 9 SOAP Envelope Example <SOAP-ENV:Envelope xmlns:SOAP- ENV=“http://schemas.xmlsoap.org/soap/envelope/” xmlns:xsi=“http://www.w3c.org/2001/XMLSchema- instance”http://www.w3c.org/2001/XMLSchema- instance xmlns:xsd=“http://www.w3.org/2001/XMLSchema”http://www.w3.org/2001/XMLSchema SOAP- ENV:encoding=“http://schemas.xmlsoap.org/soap/encodi ng/”>http://schemas.xmlsoap.org/soap/encodi ng/

10 168493: XML and Web Services (II/2546) 10 SOAP Header The SOAP header is represented as the first immediate child element of a SOAP envelope The Header element can also contain other attributes, such as mustUnderstand actor

11 168493: XML and Web Services (II/2546) 11 SOAP Header Example <wiley:Transaction xmlns:wiley=“http://jws.wiley.com/2002/b ooktx” SOAP-ENV:mustUnderstand=“1”> 5

12 168493: XML and Web Services (II/2546) 12 SOAP Fault Example1 SOAP- Env:MustUnderstand Header element missing http://jws.wiley.com/GetBook Price …

13 168493: XML and Web Services (II/2546) 13 SOAP Body A SOAP envelope contains a SOAP body as its child element A Body block of a SOAP message can contain any of the following: RPC method and its parameters Target application (receiver) specific data SOAP fault for reporting errors and status information

14 168493: XML and Web Services (II/2546) 14 SOAP Body Example <m:GetBookPrice xmlns:m=“http://www.wiley.com/jws.book.p riceList/”>http://www.wiley.com/jws.book.p riceList/ Developing Java Web Services </SOAP

15 168493: XML and Web Services (II/2546) 15 SOAP Fault In a SOAP message, the SOAP Fault element is used to handle errors and to find out status information. This element provides the error and /or status information It can be used within a Body element or as a Body entry

16 168493: XML and Web Services (II/2546) 16 SOAP Fault It provides the following elements to define the error and status of the SOAP message Faultcode: The faultcode element defines the algorithmic mechanism for the SOAP application to identify the fault Faultstring: The faultstring element provides a readable description of the SOAP fault Faultactor: The faultactor element provides the information about the ultimate SOAP actor Detail: The detail element

17 168493: XML and Web Services (II/2546) 17 SOAP Fault Example1 SOAP- ENV:Server Server OS Internal Failure – Reboot server http://abzdnet.net/keyso ap.asp

18 168493: XML and Web Services (II/2546) 18 SOAP Fault Example2 Client Invalide Request http://jws.wiley.com/Get Catalog

19 168493: XML and Web Services (II/2546) 19 SOAP mustUnderstand The SOAP understand attribute indicates that the processing of a SOAP header block is mandatory (the attribute value is 1) or optional (the attribute value is 0) at the target SOAP node

20 168493: XML and Web Services (II/2546) 20 SOAP Fault Example3 SOAP- Env:MustUnderstand Could not understand Header element

21 168493: XML and Web Services (II/2546) 21 SOAP Attachments A SOAP message contains the primary SOAP envelope in an XML format and SOAP attachments in any data format that can be ASCII or binary SOAP attachments are not part of the SOAP envelope but are related to the message

22 168493: XML and Web Services (II/2546) 22 SOAP Attachments The SOAP attachment part of the message is contained to a MIME boundary (defined in the Context- Type header) Each MIME part in the structure of the SOAP message is referenced using either Content-ID or Content- Location as labels for the part

23 168493: XML and Web Services (II/2546) 23 SOAP Attachments Both the SOAP header and body of the SOAP message also can refer to these labels in the message Each attachment of the message is identified with a Content-ID (typically an href attribute using a URL scheme) or Content-Location (a URI reference associated to the attachment)

24 168493: XML and Web Services (II/2546) 24 SOAP Attachment in a MIME Structure MIME-Version: 1.0 Content-Type: Multipart/Related; boundary=MIME_boundary; type=text/xml; Content-Description: SOAP message description

25 168493: XML and Web Services (II/2546) 25 SOAP Attachment in a MIME Structure --MIME_boundary -- Content-Type: text/xml; charset=UTF-8 Content-Transfer-Encoding: 8bit Content-ID: http://jws.wiley.com/coverpagedetails.x ml Content-Location: http://jws.wiley.com/coverpagedetails.xml

26 168493: XML and Web Services (II/2546) 26 SOAP Attachment in a MIME Structure <SOAP-ENV:Envelope xmlns:SOAP- ENV=“http://schemas.xmlsoap.org/so ap/envelope/”>http://schemas.xmlsoap.org/so ap/envelope/

27 168493: XML and Web Services (II/2546) 27 SOAP Attachment in a MIME Structure -- MIME_boundary -- Content-Type: image/gif Content-Transfer-Encoding: binary Content-ID: http://jws.wiley.com/DevelopingWebServices.g if Content-Location: http://jws.wiley.com/DevelopingWebServices.gif http://jws.wiley.com/DevelopingWebServices.gif --MIME_boundary --

28 168493: XML and Web Services (II/2546) 28 What is MIME? MIME: Multipurpose Internet Mail Extension A standard system for identifying the type of data contained in a file based on its extension. MIME is an Internet protocol that allows you to send binary files across the Internet as attachments to e-mail messages. This includes graphics, photos, sound and video files, and formatted text documents.

29 168493: XML and Web Services (II/2546) 29 SOAP Encoding The SOAP Encoding defines a set of rules for exposing its data types SOAP encoding also defines serialization rules for its data model using an encodingStyle attribute SOAP encoding supports both simple- and compound-type values

30 168493: XML and Web Services (II/2546) 30 SOAP Encoding Example Simple Type Values The definition of simple type values is based on the W3C XML Schema specification Examples 98765 98675.43 Java Rules

31 168493: XML and Web Services (II/2546) 31 SOAP Encoding Example Array Types: example http://www.w3.org/2001/XMLSchema SUNW IBM

32 168493: XML and Web Services (II/2546) 32 SOAP Message Exchange Model SOAP is a stateless protocol used to exchange messages between SOAP applications on a network, usually an intranet or the Internet A SOAP application is simply any piece of software that generates or processes SOAP messages

33 168493: XML and Web Services (II/2546) 33 SOAP Message Exchange Model For example, any Java application or J2EE component that uses JAX-RPC would be considered a SOAP application Because JAX-RPC is used to generate and process SOAP message The application sending a SOAP message is called the sender and the application receiving it is called the receiver

34 168493: XML and Web Services (II/2546) 34 SOAP Message Exchange Model As a SOAP message travels along the message path, its header blocks may be intercepted and processed by any number of SOAP intermediaries along the way A SOAP intermediary is both a receiver and a sender

35 168493: XML and Web Services (II/2546) 35 SOAP Message Exchange Model The applications along the message path (the initial sender, intermediaries, and ultimate receiver) are called SOAP nodes Initial Sender Sender SOAP Ultimate receiver Receiver Intermediaries

36 168493: XML and Web Services (II/2546) 36 SOAP Message Exchange Model SOAP Ultimate receiver Shipping Node Initial Sender Customer Node Sales Node Inventory Node Intermediaries

37 168493: XML and Web Services (II/2546) 37 SOAP Actor The SOAP actor global attribute with a URI value can be used in the Header element SOAP defines an actor with a URI value, which identifies the name of the SOAP receiver node as an ultimate destination

38 168493: XML and Web Services (II/2546) 38 SOAP Actor Example WebServices http://www.wiley.com/BookSer vice/http://www.wiley.com/jws/

39 168493: XML and Web Services (II/2546) 39 SOAP Communication To enable communication between SOAP nodes, SOAP supports the following two types of communication models SOAP RPC: It defines a remote procedural call-based synchronous communication SOAP Messaging: It defines a document- driven communication where SOAP nodes send and receive XML-based documents using synchronous and asynchronous messaging

40 168493: XML and Web Services (II/2546) 40 SOAP RPC The SOAP RPC representation defines a tightly coupled communication model based on requests and responses Using RPC conventions, the SOAP message is represented by method names with zero or more parameters and return values

41 168493: XML and Web Services (II/2546) 41 SOAP Request RPC-Based <m:GetBookPrice xmlns:m=“http://www.wiley.com/jws.book. priceList”>http://www.wiley.com/jws.book. priceList Developing Java Web Services

42 168493: XML and Web Services (II/2546) 42 SOAP Response RPC-Based http://www.wiley.com/jws.b ook.priceList 50.00

43 168493: XML and Web Services (II/2546) 43 SOAP Messaging SOAP Messaging represents a loosely coupled communication model based on message notification and the exchange of XML documents The SOAP sender node sends a message with an XML document as its body message and the SOAP receiver node processes it

44 168493: XML and Web Services (II/2546) 44 SOAP Message-Based http://www.w3.org/2001/12/so ap-envelope http://jws.wiley.com/Inventory J687

45 168493: XML and Web Services (II/2546) 45 SOAP Message-Based http://jws.wiley.com/product Developing Java Web Services 25000 2002-07-01

46 168493: XML and Web Services (II/2546) 46 SOAP Bindings for Transport Protocols The SOAP specifications do not specify and mandate any underlying protocols between the SOAP nodes SOAP can be used over a variety of transport protocols, such as HTTP, SMTP, POP3 and FTP

47 168493: XML and Web Services (II/2546) 47 SOAP Request Message Using HTTP POST /GetBookPrice HTTP/1.1 User Agent: Mozilla/4.0 (Linux) Host: krunapon:8080 Content-Type: text/xml; charset=“utf-8” Content-length: 546 SOAPAction “/GetBookPrice....

48 168493: XML and Web Services (II/2546) 48 SOAP Response Message Using HTTP HTTP/1.1 200 OK Connection: close Content-Length: 524 Content-Type: text/xml; charset=“utf-8” Date: Fri, 3 May 2002 05:05:04 GMT Server: Apache/1.3.0 …

49 168493: XML and Web Services (II/2546) 49 SOAP Message Exchange Patterns The most common SOAP messaging patterns are as follows One-way message. The SOAP client application sends SOAP messages to its SOAP server without any response being returned Request/response exchange. In this pattern, the SOAP client sends a request message that results in a response message from the SOAP server to the client

50 168493: XML and Web Services (II/2546) 50 SOAP Message Exchange Patterns Common SOAP messaging patterns Request/N*Response pattern. It is similar to a request/response pattern, except the SOAP client sends a request that results in zero to many response messages from the SOAP server to the client Notification pattern. The SOAP server sends messages to the SOAP client like an event notification, without regard to a response

51 168493: XML and Web Services (II/2546) 51 SOAP Message Exchange Patterns Common SOAP messaging patterns Solicit-response pattern. The SOAP server sends a request message to the SOAP client like a status checking or an audit and the client sends out a response message

52 168493: XML and Web Services (II/2546) 52 SOAP Message Exchange Patterns SOAP Client SOAP Server SOAP Request Message SOAP Response Message SOAP Client SOAP Client SOAP Server SOAP Message One-way message pattern Request/Response pattern SOAP Client

53 168493: XML and Web Services (II/2546) 53 SOAP Message Exchange Patterns SOAP Client SOAP Server SOAP Request Message SOAP Response Message Request/N*Response pattern

54 168493: XML and Web Services (II/2546) 54 SOAP Message Exchange Patterns SOAP Server SOAP Message(s) Notification pattern SOAP Client SOAP Client SOAP Server SOAP Message SOAP Response Message Solicit-response pattern


Download ppt "SOAP Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University."

Similar presentations


Ads by Google