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中的。
