Sunday, 12 October 2014

All About : SOAP

In this post, let us try to explore more about SOAP which stands for Simple Object Access Protocol. This is one of the ways of protocols used for coding web services. Please read through my earlier post(Must Know Basics: Web Services) on web services to get a background on this topic.

SOAP is simple and open standard XML based communication protocol for exchanging information between applications. SOAP uses HTTP (Hyper Text Transfer Protocol) as a transport protocol.SOAP provides a way to communicate between applications running on different operating systems, with different technologies and programming languages.

A SOAP message is an ordinary XML document with the following elements:
* Envelope (mandatory)- defines the start and end of the message
* Header   (Optional) - contains header information and provides optional attributes
* Body     (mandatory)- contains the call and response information
* Fault    (optional) - contains status and error information

WSDL (Web Service Description Language) is a common temr that you hear around SOAP. I would like to give you the basic idea of WSDL before we talk more about SOAP.
* WSDL is a simple XML document which describes a web service
* WSDL is a W3C recommendation
* It is also used to locate web services
If you have a web service endpoint, you can extract the WSDL using a web service testing tool. WSDL will give you a basic idea on how the request and response look like and other informaiton like the data types that can be passed in various attributes and parameters in the SOAP request.

Here is the simplified fraction of a WSDL document.


Below is a skeleton SOAP message


Let us try and invoke some sample SOAP based web service from this page http://www.service-repository.com/

Before that you need to know how to use SOAP-UI (Web Service Testing Tool). If you do not have idea on this, I would suggest you to go to the link..

I've picked up a SOAP service which gives you weather information of a city by taking the ZIP code as input.

Here is the SOAP request:


Response:

I hope this gave you a better understanding of SOAP based web services. Please feel free to write to me or leave your valuable feedback in the comments.

4 comments: