Web service中的RPC和document选择

Document: the content of <soap:Body> is specified by XML Schema defined in the <wsdl:type> section. It does not need to follow specific SOAP conventions. In short, the SOAP message is sent as one "document" in the <soap:Body> element without additional formatting rules having to be considered. Document style is the default choice.

RPC: The structure of an RPC style <soap:Body> element needs to comply with the rules specified in detail in Section 7 of the SOAP 1.1 specification. According to these rules, <soap:Body> [color=red]may contain only one element[/color] that is named after the operation, [color=red]and all parameters must be represented as sub-elements of this wrapper element.[/color]


The decisive question now is: What are the consequences of choosing one option or another? Why choose RPC over document, or document over RPC? In many cases, the SOAP messages generated from either RPC or document style WSDLs look exactly the same - so why offer the choice at all? The reason may be found in the history of the SOAP standard.

SOAP has its roots in synchronous remote procedure calls over HTTP and the appearance of the document accordingly followed these conventions. Later, it was seen as a simplification to use arbitrary XML in the SOAP body without adhering to conventions. This preference is reflected in the document style WSDL documents. So far, both options are represented in the WSDL specification and the choice of one or the other is mainly a question of personal taste since most SOAP clients today accept both versions.

document的的body可以包含多个子元素,而rpc格式的最多只能有一个子元素,参数包含在该子元素下。实际上大多数的soap信封的格式从外表看来都是一样的。至于选择哪种方式看个人口味
rpc
<SOAP:Body>
<rpc-operation>
<message-part-1><!-- mapped to a parameter-- >
<message-part-2><!-- mapped to a parameter-- >
</rpc-operation>
</SOAP:Body>
document
<SOAP:Body>
<message-part-1> ...
<message-part-2> ...
</SOAP:Body>


然而, 以目前來說, 不管是.NET 或 JAVA, 並沒有將這兩種 operation 的實作方式明顯
的區分, 一搬來說, 不管是 RPC Operation 亦或是 Document Operation, 後端都是以
一個 Method 來實作, 本質上都是 RPC.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值