Difference between SOAP and HTTP protocol

There are two main protocols related to web services.

  • 1st, transport protocols – e.g. HTTP(commonly used), TCP, UDP
  • 2nd, messaging protocols – e.g. SOAP, XML, JSON or binary encoded messages

Generally speaking,

  • Messaging protocols are responsible for exchanging the messages in a commonly agreed format.
  • Transport protocols are responsible for delivering the messages and how it should communicate.

A real world example: HTTP is like telephone communication, SOAP is like English.

You call the web service over HTTP in SOAP messages such as you call your friend by mobile phone and talking in English.

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.1Host: www.example.orgContent-Type: application/soap+xml; charset=utf-8Content-Length: nnn---------  SOAP portion of the message ------ <?xml version="1.0"?><soap:Envelopexmlns: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: