Difference between SOAP and HTTP protocol?

user0 picture user0 · Oct 8, 2013 · Viewed 55.5k times · Source

What is the difference between the SOAP and HTTP protocol. When we say "SOAP over HTTP", what does that mean.?

Answer

lreeder picture lreeder · Oct 8, 2013

You can serve any content over HTTP such as HTML, images, sound, video, etc. SOAP is an XML-based encoding of messages that are typically sent over HTTP, but could be sent over SMTP or even FTP, although I've never seen such a system used in a production environment.

Just like HTTP sits on top of TCP/IP, SOAP sits on top of HTTP. Layers on top of layers...

If you look at a SOAP request, you can see both layers, with the HTTP headers at the top, followed by the SOAP message. From the w3schools SOAP tutorial:

---------  HTTP portion of the message ------ 
POST /InStock HTTP/1.1
Host: www.example.org
Content-Type: application/soap+xml; charset=utf-8
Content-Length: nnn

---------  SOAP portion of the message ------ 
<?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.example.org/stock">
  <m:GetStockPrice>
    <m:StockName>IBM</m:StockName>
  </m:GetStockPrice>
</soap:Body>

</soap:Envelope>

More reading for you: