SOAP Protocol

By | 2013 年 12 月 28 日

SOAP – Simple object access protocol, based on the HTTP, using in the information transferring between endpoints on the Internet.
SOAP – 简单对象存取协议,基于HTTP,是一个用来在Internet上传输信息的标准

SOAP package from sender (发送方的例子)

The package from sender in like below:
发送方的代码如下:

<?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:Header>
  ...
  ...
</soap:Header>

<soap:Body>
  ...
  ...
  <soap:Fault>
    ...
    ...
  </soap:Fault>
</soap:Body>

</soap:Envelope>

The namespaces and the Envelope in the example are forced to be present. the Header is optional.
其中命名空间和Envelop标签都是必须的,Header标签是可选的。
In the Body, the sender can have what ever it want to be there, but must follow the XML rules.
在Body标签中,应用程序可以放入其需要传输的任何内容。

The response from receiver (接收方的反馈)

<?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>
   <m:GetPriceResponse xmlns:m="http://www.w3school.com.cn/prices">
      <m:Price>1.90</m:Price>
   </m:GetPriceResponse>
</soap:Body>

</soap:Envelope>

In this manner, the endpoints exchange informations through internet.
终端之间就是通过这种简单的方式进行数据传输的。

Using in Ruby – SOAP4R (Ruby中的gem – SOAP4R)

http://www.tutorialspoint.com/ruby/ruby_web_services.htm

Reference (参考)

http://w3school.com.cn/soap/index.asp

发表评论

电子邮件地址不会被公开。 必填项已用*标注