Arrao4u

…a blog by Rama Rao

Archive for the ‘SoAP’ Category

SOAP

Posted by arrao4u on December 15, 2009

Simple Object Access Protocol (SOAP) is a way to structure data so that any computer program in any language can read SOAP and send messages in SOAP.

The classic SOAP example involves an application needing to know the latest stock price for a certain company. Your application sends a request for information to a remote computer that has the stock price information. That remote computer hears your request via SOAP, and returns the stock price. This type of interaction is known as request-response, and it’s how the Web currently works (you ask a server for a Web page, and the server gives it to you).

Here’s all the code for the two messages. Example 1–1 shows the request.

Example 1–1 Example SOAP request

<env:Envelope
    xmlns:env="http://www.w3.org/2001/06/soap-envelope">
    <env:Body>
            <m:getStockPrice
            env:encodingStyle="http://www.w3.org/2001/06/
            soap-encoding" xmlns:m="http://www.wire-
            man.com/services/stockquotes">
                <symbol>PSFT</symbol>
            </m:getStockPrice>
    </env:Body>
<env:Envelope>

Example 1–2 shows what the response might look like:

Example 1–2 Example of SOAP response

<env:Envelope xmlns:env="http://www.w3.org/2001/06/soap-envelope">
        <env:Body>
            <m:getStockPriceResponse
            env:encodingStyle="http://www.w3.org/2001/06/
            soap-encoding" xmlns:m="http://www.wire-
            man.com/services/stockquotes">
            <price>45.89</price>
            </m:getStockPriceResponse>
        </env:Body>
</env:Envelope>


Soap Message

A SOAP message consists of several elements, most notably an envelope. The envelope encapsulates the data transmitted within the SOAP message. Below is a simple SOAP message complete with HTTP headers:
POST /demo/MSDN/PerfCounter.asmx HTTP/1.1
Connection: Keep-Alive
Content-Length: 150
Content-Type: text/xml
Host: localhost
User-Agent: MS Web Services Client Protocol 1.0.2204.19
SOAPAction: "http://tempuri.org/PerfCounters"

<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
               xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
               xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" 
               xmlns:xsd="http://www.w3.org/1999/XMLSchema">
  <soap:Body>
    <PerfCounters xmlns="http://tempuri.org/"/>
  </soap:Body>
</soap:Envelope>

In the example above, we see the HTTP headers for the request, including the HTTP SOAPAction header, which is optionally used by the server for routing the SOAP message. Following the HTTP headers we find the body of the HTTP message. The body of the HTTP message is the SOAP request for a PerfCounters Web Service, which we are going to build.

Posted in SoAP | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.