第十一章 SOAP 消息变体 - 消息变体的例子
消息变体的例子
作为参考,本节展示了不同模式下的消息示例(不建议使用document/encoded
模式)。
Wrapped Document/Literal
这是最常见的消息样式(也是 web
服务的默认消息样式)。
<SOAP-ENV:Envelope xmlns:SOAP-ENV='https://schemas.xmlsoap.org/soap/envelope/'
xmlns:xsi='https://www.w3.org/2001/XMLSchema-instance'
xmlns:s='https://www.w3.org/2001/XMLSchema'>
<SOAP-ENV:Body>
<MyMethod xmlns="https://www.demoservice.org">
<A>stringA</A>
<B>stringB</B>
<C>stringC</C>
</MyMethod>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Message/Unwrapped Document/Literal
这是前一种风格的轻微变化。
<SOAP-ENV:Envelope xmlns:SOAP-ENV='https://schemas.xmlsoap.org/soap/envelope/'
xmlns:xsi='https://www.w3.org/2001/XMLSchema-instance'
xmlns:s='https://www.w3.org/2001/XMLSchema'>
<SOAP-ENV:Body>
<A xmlns="https://www.demoservice.org">stringA</A>
<B xmlns="https://www.demoservice.org">stringB</B>
<C xmlns="https://www.demoservice.org">stringC</C>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
RPC/Encoded
这是第二常见的样式。下面显示了SOAP 1.1
的rpc/编码
消息:
<SOAP-ENV:Envelope xmlns:SOAP-ENV='https://schemas.xmlsoap.org/soap/envelope/'
xmlns:xsi='https://www.w3.org/2001/XMLSchema-instance'
xmlns:s='https://www.w3.org/2001/XMLSchema'
xmlns:SOAP-ENC='https://schemas.xmlsoap.org/soap/encoding/'
xmlns:tns='https://www.demoservice.org'
xmlns:types='https://www.demoservice.org'>
<SOAP-ENV:Body SOAP-ENV:encodingStyle='https://schemas.xmlsoap.org/soap/encoding/'>
<types:MyMethod>
<A>stringA</A>
<B>stringB</B>
<C>stringC</C>
</types:MyMethod>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
对于SOAP 1.2
,编码规则是不同的,因此消息是不同的:
<SOAP-ENV:Envelope xmlns:SOAP-ENV='https://www.w3.org/2003/05/soap-envelope'
xmlns:xsi='https://www.w3.org/2001/XMLSchema-instance'
xmlns:s='https://www.w3.org/2001/XMLSchema'
xmlns:SOAP-ENC='https://www.w3.org/2003/05/soap-encoding'
xmlns:tns='https://www.demoservice.org'
xmlns:types='https://www.demoservice.org'>
<SOAP-ENV:Body>
<types:MyMethod SOAP-ENV:encodingStyle="https://www.w3.org/2003/05/soap-encoding">
<A>stringA</A>
<B>stringB</B>
<C>stringC</C>
</types:MyMethod>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
RPC/Literal
下面是rpc/literal
消息的一个示例:
<SOAP-ENV:Envelope xmlns:SOAP-ENV='https://schemas.xmlsoap.org/soap/envelope/'
xmlns:xsi='https://www.w3.org/2001/XMLSchema-instance'
xmlns:s='https://www.w3.org/2001/XMLSchema'
xmlns:tns='https://www.demoservice.org'>
<SOAP-ENV:Body>
<tns:MyMethod>
<tns:A>stringA</tns:A>
<tns:B>stringB</tns:B>
<tns:C>stringC</tns:C>
</tns:MyMethod>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
网友评论