What SOAP, XML and HTTP with Example

Leave a Comment

HTTP communicates over TCP/IP. HTTP is based on Request-Response mechanism. SOAP is a HTTP Request-Response protocol. SOAP is a combination of HTTP and XML.

The SOAP request can be HTTP GET ot HTTP POST request. Each request consists of two HTTP headers :content-type and content-length. The content-type specifies the MIME type and the content-length specifies the size of the message in bytes. After this header the body part begins which defines SOAP Envelop, Header, Body and Fault.

Example
The SOAP request can be
POST /mycreation HTTP/1.0
Host: www.mywebsite.com
Content-Type: text/xml; charset = utf-8
Content-Length: 500
<?xml version= "1.0" ?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV= "http://www.w3.org/2001/12/soap-envelope"
SOAP-ENV:encodingStyle= "http://www.w3.org/2001/12/soap-encoding">
       <SOAP-ENV:Body xmlns:m= "http://www.mywebsite.com/mycreation">
          <m:GetDetails>
             <m:Name>ABCD</m:Name>
             </m:GetDetails>
       </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

The SOAP response can be
HTTP/1.0 200 OK
Content-Type: text/xml; charset = utf-8
Content-Length: 500
<?xml version= "1.0" ?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV= "http://www.w3.org/2001/12/soap-envelope"
SOAP-ENV:encodingStyle= "http://www.w3.org/2001/12/soap-encoding">
       <SOAP-ENV:Body xmlns:m= "http://www.mywebsite.com/mycreation">
          <m:GetDetailsResponse>
             <m:ItemDetails>This is a my new creation</m:ItemDetails>
             </m:GetDetailsResponse>
       </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

0 comments:

Post a Comment