Friday, March 7, 2008

A Brief overview of SOAP

What is SOAP?

In computer world, SOAP is an acronym for Simple Object Access Protocol. As the name suggests it is a protocol for accessing objects located somewhere in the Internet. One of the drawbacks of classical distributed computing technologies such as CORBA and DCOM was that they were not designed to work over Internet in a secure way. SOAP overcomes the difficulties by combining the power of two most popular internet technologies, viz. XML and HTTP/HTTPS.

SOAP Request/Response

Using SOAP, We can invoke methods on the remote SOAP server objects and pass parameters to these methods. This is called SOAP request. The server, in turn, will carry out the specified method and will return the results to the client. This is called SOAP Response.

The whole communication between the client and server happens via ubiquitous HTTP GET/POST mechanism. XML handles the data structure aspect of SOAP while HTTP handles the communication with the remote objects. One of the main features of SOAP is that it is language and platform independent. For example, a Perl script running on Solaris could generate a SOAP request on a .NET based SOAP server running on a Windows system.

SOAP Request/Response Structure

A SOAP Request/Response is nothing but a XML document with specific tags. A SOAP request/response structure will have three basic components.

1) Envelope
2) Header
3) Body

Envelope

SOAP envelope contains the whole information that is passed from the client/server. The envelope contains both the header and body elements.

A typical SOAP envelope begins with the tag and ends with a tag. The following example shows a typical SOAP envelope along with namespace definitions. Please note that your SOAP element definition may vary.


Header

A SOAP request can have an optional Header information. The header may contain any information and it is up to the application to interpret the header.

Body

The SOAP body is what we are really interested in. If we are sending a request to the server, the body will contain the method that we want to invoke and all the parameters required by the method.

If it is a response from the server, the body will contain the result of the method invocation from the server.

Example

SOAP Request

Here is a sample SOAP request that invokes echo method and passes something as the value of param1 parameter to the echo method.





something




SOAP Response

Here is the sample SOAP response method from the SOAP server for the echo method. The output of the method is the same as input value passed to it.





something





Error handling

What if the method could not be invoked on the SOAP server possibly because insufficient arguments or due to some runtime error condition? In such case, you will receive a fault element structure in the body like the following.





error output here




More information

Of course, this article gives you a very basic introduction to SOAP. If you're interested in learning about SOAP, you could check out some of the links given below.

A nice SOAP tutorial is available at http://www.w3schools.com/soap/default.asp.

For a sample Tivoli Monitoring SOAP calls, please check out Frank Tate's blog entry at

http://www.gulfsoft.com/modules.php?op=modload&name=News&file=article&sid=118&mode=thread&order=0&thold=0

No comments: