根椐SOAP V1.2规范 SOAP包括四部份:
- SOAP Envelope(SOAP信封): 它构造定义了一个整体的表示框架,可用于表示消息(Message)中是什么,谁应当处理它,以及这是可选还是强制的.
- SOAP Envcoding Rules(SOAP编码规则): 它定义了一个编序机构,用于定义交换应用程序定义的数据类型的实例.
- SOAP PRC Representation(SOAP PRC表示): 它定义一了个用于表示远端过程调用和响应的约定.
- SOAP Binding(SOAP 邦定): 它定义了一个使用底层传输协议来完成在结点间交换SOAP信封的约定.
SOAP消息(SOAP信封)包括三个部份:
- 一个是SOAP Envelope: Envelope是表示该消息的XML文档的顶级元素.
- 一个可选的SOAP Header: Header是为了支持在松散环境下通信方(可能是SOAP发送者,SOAP接收者或者是一个或多个SOAP的传输中介)之间尚未预先达成一致的情况下为SOAP消息增加特性的通用机制.SOAP定义了很少的一些属性来用于指明谁可以处理该特性以及它是可选的还是强制的.
- 一个强制的SOAP Body: Body为该消息的最终接收者所想要得到的那些强制信息提供了一个容器.此外.SOAP定义了Body的一个子元素Fault用于报告错误.
SOAP请求:
POST/Pay/CH1/WebService1.asmx HTTP/1.1
Host:localhost
Content-Type:text/xml;charset=utf-8
Content-Lenght:lenght //lenght将被实际值所代替
SOAPAction: "http://tempuri.org/doSearch”
<?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:soap=”http://schemas.xmlsoap.org/soap/Envelope/”>
<soap:Body>
<doSearch xmlns=”http://tempuri.org/”>
<keyword>string</keyword>
</doSearch>
</soap:Body>
</soap:Envelope>
对应的SOAP响应
HTTP/1.1 200 OK
Content-Type: text/xml;charset=utf-8
Content-Length:length
<?xml version=”1.1” Encoding=”utf-8”>
<soap:Envelope xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”xmlns:xsd=”http://www.w3.org/2001/XMLSchema” xmlns:soap=”http://schemas.xmlsoap.org/soap/Envelope/”>
<soap:Body>
<doSearchRespone xmlns=”http://tempuri.org/”>
<doSearchResult>String</doSearchResult>
</doSearchResponse>
</soap:Body>
</soap:Envelope>
浙公网安备 33010602011771号