Difference between SOAP and HTTP protocol?

2019-03-08 13:41发布

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

3条回答
仙女界的扛把子
2楼-- · 2019-03-08 14:13

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:

查看更多
迷人小祖宗
3楼-- · 2019-03-08 14:27

To interact with server, request should be in XML encoded format using SOAP. But in case of HTTP, request can be sent in HTML, Image, video format etc. SOAP request are sent using HTTP protocol.

查看更多
Explosion°爆炸
4楼-- · 2019-03-08 14:35

SOAP stands for Simple Object Access protocol. It is XML based used for sending and receiving messages. It is defined with in XML.

Example.

<?xml version="1.0"?>

<soap:Envelope
xmlns:soap="http://www.example/2003/05/soap-envelope/"
soap:encodingStyle="http://www.example.com/2003/05/soap-encoding">

<soap:Body>
  <m:GetPriceResponse xmlns:m="http://www.example.com/prices">
    <m:Price>1.90</m:Price>
  </m:GetPriceResponse>
</soap:Body>

</soap:Envelope> 

stands for Simple Mail Transfer Protocol. Simple Mail Transfer Protocol is a way to transfer email reliably and efficiently. is used to send mail to the recipient's mailbox,thus using various methods to access the emails in his mailbox. by default uses port 25. The protocol for mail submission is the same, but uses port 587. connections secured by [SSL], known as , default to port 465 (nonstandard, but sometimes used for legacy reasons). We can send messages synchronously or asynchronously. Sessions can be automatically managed.

SOAP is language dependent, But SMTP is Language independent. SOAP is mainly used for XML webservices. SMTP is also using protocol to get or post information.

查看更多
登录 后发表回答