Section 22.3. Simple Object Access Protocol (SOAP)


22.3. Simple Object Access Protocol (SOAP)

The Simple Object Access Protocol (SOAP) is a platform-independent protocol that uses XML to make remote procedure calls, typically over HTTP. Each request and response is packaged in a SOAP messagean XML message containing the information that a Web service requires to process the message. SOAP messages are written in XML so that they are human readable and platform independent. Most firewallssecurity barriers that restrict communication among networksdo not restrict HTTP traffic. Thus, XML and HTTP enable computers on different platforms to send and receive SOAP messages with few limitations.

Web services also use SOAP for the extensive set of types it supports. The wire format used to transmit requests and responses must support all types passed between the applications. SOAP types include the primitive types (e.g., Integer), as well as DateTime, XmlNode and others. SOAP can also transmit arrays of all these types. In addition, DataSets can be serialized into SOAP. In Section 22.7, you will see that you can transmit user-defined types in SOAP messages.

When a program invokes a Web method, the request and all relevant information are packaged in a SOAP message and sent to the server on which the Web service resides. When the Web service receives this SOAP message, it begins to process the contents (contained in a SOAP envelope), which specify the method that the client wishes to execute and any arguments the client is passing to that method. This process of interpreting a SOAP message's contents is known as parsing a SOAP message. After the Web service receives and parses a request, the proper method is called with the specified arguments (if there are any), and the response is sent back to the client in another SOAP message. The client parses the response to retrieve the result of the method call.

The SOAP request in Fig. 22.8 was taken from the test page for the HugeInteger Web service's Bigger method (Fig. 22.4). Visual Basic 2005 creates such a message when a client wishes to execute the HugeInteger Web service's Bigger method. If the client is a Web application, Visual Web Developer creates the SOAP message. The message in Fig. 22.8 contains placeholders (length in line 4 and string in lines 1617) representing values specific to a particular call to Bigger. If this were a real SOAP request, elements first and second (lines 1617) would each contain an actual value passed from the client to the Web service, rather than the placeholder string. For example, if this envelope were transmitting the request from Fig. 22.4, element first and element second would contain the numbers displayed in the figure, and placeholder length (line 4) would contain the length of the SOAP message. Most programmers do not manipulate SOAP messages directly, but instead allow the .NET framework to handle the transmission details.

Figure 22.8. SOAP request message for the HugeInteger Web service.

  1  POST /HugeInteger/HugeInteger.asmx HTTP/1.1  2  Host: localhost  3  Content-Type: text/xml; charset=utf-8  4  Content-Length: length  5  SOAPAction: "http://www.deitel.com/Bigger"  6  7  <?xml version="1.0" encoding="utf-8"?>  8  9  <soap:Envelope 10     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 11     xmlns:xsd="http://www.w3.org/2001/XMLSchema" 12     xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 13 14    <soap:Body> 15      <Bigger xmlns="http://www.deitel.com"> 16        <first>string</first> 17        <second>string</second> 18      </Bigger> 19     </soap:Body> 20  </soap:Envelope> 



Visual BasicR 2005 for Programmers. DeitelR Developer Series
Visual Basic 2005 for Programmers (2nd Edition)
ISBN: 013225140X
EAN: 2147483647
Year: 2004
Pages: 435

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net