Appendix G. Simple Object Access Protocol

Simple Object Access Protocol (SOAP) is a simple and lightweight protocol for exchanging structured information between network applications in a distributed environment using extended Markup Language (XML). IBM, Microsoft, and others submitted SOAP to the World Wide Web Consortium (W3C) as the basis of XML protocol working group. SOAP is becoming popular as the chosen XML messaging protocol for several reasons:

  • Simplicity

  • Standardized enveloping mechanism that allows business documents to be transmitted using standard Internet protocols such as Hyper Text Transfer Protocol (HTTP)

  • Support for the publish, find, and bind operations in the Web services architecture

  • Programming language and platform independent

The SOAP protocol can be used in combination with other network protocols such as HTTP, Internet Inter-ORB Protocol (IIOP), and File Transfer Protocol (FTP). SOAP can be used to facilitate interobject communication across a network. In such a scenario, the objects communicate with each other, by exchanging SOAP messages. This is, in effect, a Remote Procedure Call (RPC) mechanism.

SOAP Message Components

A SOAP message consists of three parts:

  1. The SOAP envelope: defines the framework for describing what is in a message, which should deal with it and whether it is optional or mandatory.

  2. The SOAP encoding rules: define serialization mechanism to exchange instances of application-defined data types.

  3. The SOAP RPC: defines a convention for representing remote procedure calls and responses.

Under a typical scenario, based on the Web services, a service requestor or service provider should be able to build and parse a SOAP message and communicate over the network. A SOAP server running in a Web application server performs these functions for the service provider or service requestor.

The code segments below provide a sample SOAP request message and corresponding response.

Sample SOAP Request Message:

<?xml version=’1.0’ encoding=’UTF-8’?> 
<soap:Envelope 
  xmlns:xsi=’http://www.w3.org/2001/XMLSchema-instance’ 
xmlns:xsd=’http://www.w3.org/2001/XMLSchema’ 
  xmlns:soap=’http://schemas.xmlsoap.org/soap/envelope/’ 
  xmlns:soapenc=’http://schemas.xmlsoap.org/soap/encoding/’ 
  soap:encodingStyle= 
    ’http://schemas.xmlsoap.org/soap/encoding/’> 
    <soap:Body> 
      <n:getOSName 
        xmlns:n=’http://tempuri.org/SysteminfoService’> 
        <arg0 xsi:type=’xsd:string’>Hello</arg0> 
        <arg1 xsi:type=’xsd:string’>Shilpa</arg1> 
      </n:getOSName> 
  </soap:Body> 
</soap:Envelope> 

Sample SOAP Response Message:

<?xml version=’1.0’ encoding=’UTF-8’?> 
<soap:Envelope 
  xmlns:xsi=’http://www.w3.org/2001/XMLSchema-instance’ 
  xmlns:xsd=’http://www.w3.org/2001/XMLSchema’ 
  xmlns:soap=’http://schemas.xmlsoap.org/soap/envelope/’ 
  xmlns:soapenc=’http://schemas.xmlsoap.org/soap/encoding/’ 
  soap:encodingStyle= 
    ’http://schemas.xmlsoap.org/soap/encoding/’> 
  <soap:Body> 
    <n:getOSNameResponse 
      xmlns:n=’http://tempuri.org/SysteminfoService’> 
      <Result xsi:type=’xsd:string’> 
        Hello Shilpa the OS is: Windows 2000 
      </Result> 
    </n:getOSNameResponse> 
  </soap:Body> 
</soap:Envelope> 

In these sample messages, the tag getOSNameResponse is the method name with XML namespace http://tempuri.org/SysteminfoService. A SOAP server can choose a specific XML namespace to use. Some SOAP servers also provide flexibility to the user to provide the namespace for certain tags. All the namespaces used in the SOAP message are declared in the SOAP envelope section of the message.

In the request message, the tags arg0 and arg1 represent the arguments passed to the method. These tags contain the data type of these arguments and the actual values of these arguments.

In the response message, the tag result represents the return value of the method. It contains the data type and the actual return value.

SOAP was developed by Microsoft, DevelopMentor, and Userland Software and has been proposed as a standard interface to the Internet Engineering Task Force (IETF). The SOAP specification is available at http://www.w3.org/TR/SOAP/.

Attachments to SOAP Messages

The SOAP specification allows attachments to be included in SOAP messages. These attachments can be related to either SOAP header or SOAP body. The specification provides information on how to include binary or text attachments to a SOAP message and package them all as a multipart Multi-Purpose Internet Mail Extensions (MIME) format. Using this, any additional information to a core SOAP message can be sent within the same transaction. Document Exchange Model (DEM)-based Web services can use SOAP attachments to send or receive multiple XML documents as part of a service request or corresponding response. More information on the SOAP attachments and their usage can be found at: http://www.w3.org/TR/SOAP-attachments.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset