wsdl:binding中 style: "document" 和 RPC 区别

本文对比了WebService中的RPC模型和Document模型。RPC模型基于远程方法调用,适用于简单的请求响应模型;Document模型则通过完整的业务文档进行交互,更加灵活且支持异步处理。推荐使用Document模型,因为它提供了更好的低耦合性和利用XML的功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

RPC模型  
   RPC 是远程方法的调用。尽管WebService是基于XML的但是你仍然可以使用远程方法调用这种模式来进行WebService的实现,尤其是在那种简单的请求相应的模型中。在这个过程中,传输中的XML文件所描述的更多是有关远程方法的信息。

Document模型 
   Document方式,与RPC相比较在XML文件中不是做远程方法的映射,而是一份完整的自包含的业务文档,当Service端收到这份文档后,先进行预处理(比如词汇的翻译和映射),然后再构造出返回消息。这个构造返回消息的过程中,往往不再是简简单单的一个方法调用,而是多个对象协同完成一个事务的处理,再将结果返回。  


  这两种方式的区别:对于第一种方法提供了很多自动化的工具使得远程方法的调用能够很容易的完成,而后一种方法缺少一系列工具的支持,需要开发者手工完成。  
  推荐使用Document方式。由于它在以下方面具有RPC所不具备的优点。  
  使用Document方式,你可以充分利用XML的功能去描述和验证一份业务文档,而在RPC模型中XML仅仅被用于描述方法的信息。  
  使用Document方式,在客户的Service的提供者之间不再需要紧密的约定,而RPC模型需要客户和Service的提供者紧密相连,一旦方法发生变化,客户端就需要做相应的改动。这不符合低耦合系统的要求,而在文档交换方式中则灵活的多。  
  由于业务数据是自包含的,显然文档模型更利于采用异步处理。 

 

我应该采用哪一种 WSDL 样式?
http://www-128.ibm.com/developerworks/cn/webservices/ws-whichwsdl/

<wsdl:definitions xmlns:wsdl=&quot;http://schemas.xmlsoap.org/wsdl/&quot; xmlns:ns=&quot;urn:rmyy:service&quot; xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:ns1=&quot;http://org.apache.axis2/xsd&quot; xmlns:soap=&quot;http://schemas.xmlsoap.org/wsdl/soap/&quot; xmlns:soap12=&quot;http://schemas.xmlsoap.org/wsdl/soap12/&quot; xmlns:http=&quot;http://schemas.xmlsoap.org/wsdl/http/&quot; xmlns:mime=&quot;http://schemas.xmlsoap.org/wsdl/mime/&quot; xmlns:wsaw=&quot;http://www.w3.org/2006/05/addressing/wsdl&quot; targetNamespace=&quot;urn:rmyy:service&quot;> <wsdl:documentation>rmyy</wsdl:documentation> <wsdl:types> <xs:schema attributeFormDefault=&quot;qualified&quot; elementFormDefault=&quot;qualified&quot; targetNamespace=&quot;urn:rmyy:service&quot;> <xs:element name=&quot;rmyyService&quot;> <xs:complexType> <xs:sequence> <xs:element minOccurs=&quot;0&quot; name=&quot;userName&quot; nillable=&quot;true&quot; type=&quot;xs:string&quot;/> <xs:element minOccurs=&quot;0&quot; name=&quot;password&quot; nillable=&quot;true&quot; type=&quot;xs:string&quot;/> <xs:element minOccurs=&quot;0&quot; name=&quot;svcCode&quot; nillable=&quot;true&quot; type=&quot;xs:string&quot;/> <xs:element minOccurs=&quot;0&quot; name=&quot;inputXml&quot; nillable=&quot;true&quot; type=&quot;xs:string&quot;/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name=&quot;rmyyServiceResponse&quot;> <xs:complexType> <xs:sequence> <xs:element minOccurs=&quot;0&quot; name=&quot;return&quot; nillable=&quot;true&quot; type=&quot;xs:string&quot;/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> </wsdl:types> <wsdl:message name=&quot;rmyyServiceRequest&quot;> <wsdl:part name=&quot;parameters&quot; element=&quot;ns:rmyyService&quot;/> </wsdl:message> <wsdl:message name=&quot;rmyyServiceResponse&quot;> <wsdl:part name=&quot;parameters&quot; element=&quot;ns:rmyyServiceResponse&quot;/> </wsdl:message> <wsdl:portType name=&quot;rmyyPortType&quot;> <wsdl:operation name=&quot;rmyyService&quot;> <wsdl:input message=&quot;ns:rmyyServiceRequest&quot; wsaw:Action=&quot;urn:rmyyService&quot;/> <wsdl:output message=&quot;ns:rmyyServiceResponse&quot; wsaw:Action=&quot;urn:rmyyServiceResponse&quot;/> </wsdl:operation> </wsdl:portType> <wsdl:binding name=&quot;rmyySoap11Binding&quot; type=&quot;ns:rmyyPortType&quot;> <soap:binding transport=&quot;http://schemas.xmlsoap.org/soap/http&quot; style=&quot;document&quot;/> <wsdl:operation name=&quot;rmyyService&quot;> <soap:operation soapAction=&quot;urn:rmyyService&quot; style=&quot;document&quot;/> <wsdl:input> <soap:body use=&quot;literal&quot;/> </wsdl:input> <wsdl:output> <soap:body use=&quot;literal&quot;/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:binding name=&quot;rmyySoap12Binding&quot; type=&quot;ns:rmyyPortType&quot;> <soap12:binding transport=&quot;http://schemas.xmlsoap.org/soap/http&quot; style=&quot;document&quot;/> <wsdl:operation name=&quot;rmyyService&quot;> <soap12:operation soapAction=&quot;urn:rmyyService&quot; style=&quot;document&quot;/> <wsdl:input> <soap12:body use=&quot;literal&quot;/> </wsdl:input> <wsdl:output> <soap12:body use=&quot;literal&quot;/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:binding name=&quot;rmyyHttpBinding&quot; type=&quot;ns:rmyyPortType&quot;> <http:binding verb=&quot;POST&quot;/> <wsdl:operation name=&quot;rmyyService&quot;> <http:operation location=&quot;rmyyService&quot;/> <wsdl:input> <mime:content type=&quot;application/xml&quot; part=&quot;parameters&quot;/> </wsdl:input> <wsdl:output> <mime:content type=&quot;application/xml&quot; part=&quot;parameters&quot;/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name=&quot;rmyy&quot;> <wsdl:port name=&quot;rmyyHttpSoap11Endpoint&quot; binding=&quot;ns:rmyySoap11Binding&quot;> <soap:address location=&quot;http://172.17.0.87:8090/ws/services/rmyy.rmyyHttpSoap11Endpoint/&quot;/> </wsdl:port> <wsdl:port name=&quot;rmyyHttpSoap12Endpoint&quot; binding=&quot;ns:rmyySoap12Binding&quot;> <soap12:address location=&quot;http://172.17.0.87:8090/ws/services/rmyy.rmyyHttpSoap12Endpoint/&quot;/> </wsdl:port> <wsdl:port name=&quot;rmyyHttpEndpoint&quot; binding=&quot;ns:rmyyHttpBinding&quot;> <http:address location=&quot;http://172.17.0.87:8090/ws/services/rmyy.rmyyHttpEndpoint/&quot;/> </wsdl:port> </wsdl:service> </wsdl:definitions>怎么在postman请求这个接口
最新发布
06-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值