Search This Blog

Saturday, April 21, 2012

SOAP for Webservices- Quick Introduction


Quite often than not IT infrastructure of an organization is made up of multiple vendor providing solutions using multiple technologies, Lot of Replication of data stores and functionality is required for communication between these multiple vendor systems to alleviate this XML standard was introduced.
   Though XML provide flexibility to structure data for developer but for better communication between disparate systems some rules for structuring data in xml document are needed, such rules will pave a way higher degree of automation in communication. Simple Object Access Protocol (SOAP) provides the rule that will
Help to standardize the communication using xml document.
    SOAP let us to expose and consume complex data structures e.g. dataset or table.


More about SOAP
     "Simple Object Access Protocol" was designed to be a platform and language-neutral alternative to previous middleware technologies like CORBA and DCOM. SOAP was also designed from the ground up to be extensible, so that other standards could be integrated into it
A SOAP message is an ordinary XML document containing the following elements.
·         Envelope: (Mandatory)
defines the start and the end of the message.
·         Header: (Optional )
Contains any optional attributes of the message used in processing the message, either at an intermediary point or at the ultimate end point.
·         Body: (Mandatory)
Contains the XML data comprising the message being sent.
·         Fault: ( Optional )
An optional Fault element that provides information about errors that occurred while processing the message
For details about of SOAP please refer links provide in reference section of article.
Here is a link to a site that let you to see by naked eye how soap request and soap response may look like

A SOAP Example


If a request is send to web service to invoke GetAccountBalance method having AccountCode as input parameter which returns Balance and the namespace for the function is defined in http://www.conflux.org/accountbalance then SOAP request and SOAP Response may look like

A SOAP request:


POST /URL_FromWhichCallMade HTTP/1.1
Host: www. conflux.org
Content-Type: application/soap+xml; charset=utf-8
Content-Length: nnn

<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

<soap:Body xmlns:m=" http://www.conflux.org/accountbalance ">
  <m: GetAccountBalance >
    <m: AccountCode >00888786555</m: AccountCode >
  </m: GetAccountBalance >
</soap:Body>
</soap:Envelope>

The SOAP response:

HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: nnn

<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

<soap:Body xmlns:m="http://www.conflux.org/accountbalance">
  <m: GetAccountBalance >
    <m: Balance >4523</m: Balance >
  </m: GetAccountBalance >
</soap:Body>

</soap:Envelope>

Here we have seen how soap request & soap response look like point to note that both are XML document with additional soap related nodes.

<soap:Envelope> act as root just like <html> in any html page,   it contain <soap:Body>
Just like <body> tag in html. <soap:Envelope> can also contain <soap:Header>
 <soap:Fault>.
References:


No comments:

Post a Comment