日期:2008-10-28  浏览次数:20498 次

   soap只是一种协议,是一种简单的基于xml的协议,用于在web上交换结构和类型信息,从它的名字(soap , simple object access protocol,简单物件访问协议)就能够看出设计的目的是为使信息交换尽可能的简单。soap只是一个框架,它可以以http为载体,也可以通过其他如ftp,smtp甚至一张软盘来实现,不过普通情况下都是采用http协议,所以好像给人的印象是soap必须基于http。另外,既然soap是一种协议,那它就不意味着一定要服务于webservice。
至于soap有rpc和xml的http的2种模式这种说法不够正确,首先soap就是基于xml的,另外rpc call通过http来做,下边是个名字叫"echoString"的rpc方法调用的soap request:
POST /test/simple.asmx HTTP/1.1
Host: 131.107.72.13
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://soapinterop.org/echoString"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://soapinterop.org/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <tns:echoString>
      <inputString>string</inputString>
    </tns:echoString>
  </soap:Body>
</soap:Envelope>
你可以看到,方法名echoString是包含在soap body中的。