Web Service中RPC和Document的区别

来自国外论坛的通俗易懂的回答: 

With Document/Literal encoding, the payload of a message is an XML fragment that can be validated against the corresponding XML schema, for instance: 

  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <soap:Envelope  
  3.     xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"  
  4.     xmlns:mi="http://www.somedomain.com/xyz/message-id"  
  5.     xmlns:proc="http://www.somedomain.com/xyz/processed-by"  
  6.     xmlns:po="http://www.books.com/purchase">  
  7.     <soap:Header/>  
  8.     <soap:Body>  
  9.         <po:purchaseOrder orderDate="2008-09-22"  
  10.             xmlns:po="http://www.somedomain.com/xyz/PO">  
  11.             <po:accountName>Books.com</po:accountName>  
  12.             <po:accountNumber>923</po:accountNumber>  
  13.             ...  
  14.             <po:book>  
  15.                 <po:title>Air Guitars In Action</po:title>  
  16.                 <po:quantity>300</po:quantity>  
  17.                 <po:wholesale-price>14.99</po:wholesale-price>  
  18.             </po:book>  
  19.         </po:purchaseOrder>  
  20.     </soap:Body>  
  21. </soap:Envelope>  


RPC (remote procedure call)/Literal more closely corresponds to remote procedure invocations.  
For instance, the method: public float getBookPrice( String  inISBN) would correspond to the following RPC/Literal request message:  
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <soap:Envelope  
  3.  xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"  
  4.  xmlns:sd="http://www.somedomain.com/xyz/BookQuote">  
  5.    <soap:Body>  
  6.       <sd:getBookPrice>  
  7.           <isbn>0321146182</isbn>  
  8.       </sd:getBookPrice>  
  9.    </soap:Body>  
  10. </soap:Envelope>  


There is a SOAP standard XML format for RPC-style messaging. However, use and implementation of this standard is optional. 
Hope this makes things more clear!

 

One important difference between RPC and Document web services is that with RPC web services, XML schema will only be created for complex type parameters. It is thus not possible to validate the entire XML fragment contained in the SOAP body. 
With Document web services, however, the XML schema needs to define the ENTIRE XML fragment contained in the SOAP body. Consequently, the entire message can be validated against the XML schema. 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值