Understanding the Simple Object Access Protocol (SOAP)

As you read about web services on the Internet and in books and magazines, you will encounter numerous references to SOAP, the Simple Object Access Protocol. In general,

SOAP defines XML-based network messages that the proxy and web service exchange when your program calls a service method. The primary advantage of SOAP is its simplicity.

SOAP is a “lightweight” protocol that normally sits above HTTP (although SOAP can run on top of other protocols such as FTP). By building SOAP on top of HTTP, SOAP messages can travel through firewalls and can take advantage of mechanisms such as the secure sockets layer (SSL) to encrypt the data the client program exchanges with the remote server. The World Wide Web Consortium provides specifics about the SOAP protocol at www.w3c.org.

A SOAP message consists of an envelope that encompasses a message header and body. When a program calls a web service method, the message header might contain username and password information that authenticates the user at the remote server. (Chapter 8, “Authenticating Services within .NET Services,” examines authentication in detail.) The message body, in turn, will contain the method name and parameter information. The following statements correspond to the SOAP message the proxy will send to call the DateService web service DateString method:

<?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/"> <soap:Body> <DateString xmlns="http://tempuri.org/" />    </soap:Body> </soap:Envelope>

In a similar way, the following statements illustrate the SOAP message the web service will return to the proxy that contains the method’s result:

<?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/">    <soap:Body>      <DateStringResponse xmlns="http://tempuri.org/">    <DateStringResult> 8/26/2002</DateStringResult>      </DateStringResponse>    </soap:Body> </soap:Envelope>

As discussed in Chapter 2, a web service can return a structure or an array of values. The following statements illustrate the SOAP message a web service would return to a proxy that called the ServerInfo web service GetInfo method:

<?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/"> <soap:Body> <GetInfoResponse xmlns="http://tempuri.org/">    <GetInfoResult>         <OS>Windows</OS>         <DotNet>true</DotNet>         <SSL>true</SSL>         <Administrator>B. Gates</Administrator>         <WebServer>IIS</WebServer>       </GetInfoResult>     </GetInfoResponse>   </soap:Body> </soap:Envelope>




. NET Web Services Solutions
.NET Web Services Solutions
ISBN: 0782141722
EAN: 2147483647
Year: 2005
Pages: 161
Authors: Kris Jamsa

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