Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 SOAP Simple Object Access Protocol 大葉大學資工系. 2 Purpose of SOAP Developers need to establish a standard transport and data-exchange framework to achieve.

Similar presentations


Presentation on theme: "1 SOAP Simple Object Access Protocol 大葉大學資工系. 2 Purpose of SOAP Developers need to establish a standard transport and data-exchange framework to achieve."— Presentation transcript:

1 1 SOAP Simple Object Access Protocol 大葉大學資工系

2 2 Purpose of SOAP Developers need to establish a standard transport and data-exchange framework to achieve XML- based interaction. The reasons for using SOAP Web services require a protocol that uses a standard, open data format. Web services need a way to work with the basic security mechanisms of remote networks.

3 3 Nature of SOAP SOAP is a software system that enables applications to communicate with one another using XML-based message, called SOAP message. SOAP messages encapsulate the information exchanged. SOAP messages don’t provide programming instructions, rather, specify the operations to invoke. SOAP supports features such as attachments, security, routing information and transaction.

4 4 Flow of a SOAP Request Client-Side Consumer SOAP Message Proxy Serialize Deserialize Server-Side IIS ASPNET_ISAPI.DLL HTTP Handlers HTTP Web Service Handler Web Service Serialize Deserialize Network

5 5 SOAP Specifications SOAP envelope describes the format of a SOAP message. The second part defines a set of rules that encode data types. The third part defines how a SOAP message can execute remote procedure call (RPC). The last part specifies the message binding protocol. HTTP, HTTPS, SMTP

6 6 Anatomy of a SOAP Message A SOAP message is composed of an envelope that contains the body of the message and any header information used to describe the message. The root element of the document is the Envelope element. The envelope can contain an optional Header element, which contains information about the message. The envelope must contain one Body element.

7 7 A SOAP Envelop Header Body

8 8 SOAP Actors A SOAP actor is anything that acts on the content of the SOAP message. There are two types of SOAP actors: The default actor is the intended final recipient of a SOAP message. An intermediary receives a SOAP message and might act on the message before forwarding it along the intended message path.

9 9 Header Element The optional Header element is used to pass data that might not be appropriate to encode in the body. Authentication, Security digest information, Routing information, Transactions, Payment information. B839D234A3F87 MSFT 74.56

10 10 Body Element The body contains the payload of the message and there are no restrictions on how the body can be encoded. SOAP messages are placed into two categories: Procedure-oriented messages provide two-way communication and are commonly referred to as remote procedure call (RPC) messages. Document-oriented messages generally facilitate one-way communication. Business documents such as purchase orders are examples of document-oriented messages.

11 11 SOAP 1.1 XML Schema Definition <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.xmlsoap.org/soap/envelope/" targetNamespace="http://schemas.xmlsoap.org/soap/envelope/" > <xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax" /> <xs:anyAttribute namespace="##other" processContents="lax" />

12 12 SOAP 1.1 XML Schema Definition <xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax" /> <xs:anyAttribute namespace="##other" processContents="lax" /> <xs:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax" /> <xs:anyAttribute namespace="##any" processContents="lax" />

13 13 SOAP 1.1 XML Schema Definition

14 14 SOAP 1.1 XML Schema Definition <xs:attribute name="encodingStyle" type="tns:encodingStyle" /> <xs:element name="faultactor" type="xs:anyURI" minOccurs="0" /> <xs:element name="detail" type="tns:detail" minOccurs="0" />

15 15 SOAP 1.1 XML Schema Definition <xs:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax" /> <xs:anyAttribute namespace="##any" processContents="lax" />

16 16 SOAP Message Example <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 22-342439 98-283843 100.00

17 17 SOAP Message Example <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <x:TransferFundsResponse xmlns:x="urn:examples-org:banking"> 22-342439 33.45 98-283843 932.73

18 18 SOAP Message Example <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> soap:Server Insufficient funds 22-342439 100.00 89.23

19 19 Procedure-oriented Messages Two SOAP messages are paired together to facilitate an RPC method call with SOAP: the request message Information about the targeted method along with any input parameters is passed to the server via a request message. the corresponding response message The server invokes some behavior (or procedure) and returns the results and any return parameters.

20 20 Document-oriented Messages A business document such as a purchase order or an invoice can be encoded within the body of a SOAP message and routed to its intended recipient. The recipient of the document might or might not send an acknowledgment message back to the sender.

21 21 SOAP RPC Messages Remote Procedure Call (RPC) is a technology by which one application invokes a procedure residing on another computer. The SOAP message body contains the Web service method to be invoked, any parameters the method takes and the target procedure’s URI.

22 22 SOAP Example Add(1, 2) <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 1 2 <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 1 2 <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 3 <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 3 public int Add(int x, int y) { return x + y; }

23 23 SOAP Encoding SOAP Encoding defines the way data can be serialized within a SOAP message. SOAP Encoding builds on the types defined in the XML specification. Simple Types An instance of a data type is encoded as an XML element. integer called Age would be encoded as 31

24 24 SOAP Encoding Compound Type – Structures Each of the variables contained within the instance of the structure is serialized as a child element of the parameter element. public struct RectSolid { public int length; public int width; public int height; } public int CalcVolume(RectSolid r) { return (r.length * r.width * r.height); } 2 3 1

25 25 SOAP Encoding Compound Type – Array SOAP 1.1 specifies the encoding of Array type. public int AddArray(int[] numbers) {... } int[] a = {1, 2, 3}; int total; total = AddArray(a); <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 1 2 3

26 26 SOAP Encoding string[][] teams = new string[3][]; teams[0] = new string[3]; teams[0][0] = "Bob"; teams[0][1] = "Sue"; teams[0][2] = "Mike"; teams[1] = new string[2]; teams[1][0] = "Jane"; teams[1][1] = "Mark"; teams[2] = new String[4]; teams[2][0] = "Mary"; teams[2][1] = "Jill"; teams[2][2] = "Jim"; teams[2][3] = "Tom"; RegisterTeams(teams); public void RegisterTeams(string[][] teams) { //... } <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> Bob Sue Mike Jane Mark Mary Jill Jim Tom

27 27 Passing Parameters by Reference Fibonacci series public void FibonacciIncrement(ref int n1, ref int n2) { int temp = n2; n1 += n2; n2 = temp + n1; } int x = 1; int y = 1; for(int i = 1, i < 11, i += 2) { Console.Write("{0}, {1}", x, y); FibonacciIncrement(x, y); } <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 1 <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 1 <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 2 3 <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 2 3

28 28 Protocol Binding SOAP messages can be sent over any transport protocol that is capable of carrying XML. The SOAP specification describes only one protocol binding: sending SOAP messages via HTTP POST. It is firewall friendly. It has a robust supporting infrastructure. It is inherently stateless. It is simple. It maps nicely to RPC-style message exchanges. It is open.

29 29 Protocol Binding

30 30 HTTP Request Header: contains information about the request and about the client that sent the request. Body: follows the header and is delimited by two carriage-return/linefeed pairs. POST /SomeWebService HTTP/1.1 Content-Type: text/xml SOAPAction: "http://somedomain.com/SomeWebService.wsdl" Content-Length: 243 Host: sshort3 <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/"> 2


Download ppt "1 SOAP Simple Object Access Protocol 大葉大學資工系. 2 Purpose of SOAP Developers need to establish a standard transport and data-exchange framework to achieve."

Similar presentations


Ads by Google