RPC 和 Document Web 服务之间有许多不同之处。 RPC 和 Document 的重要区别如下:
RPC样式风格
- RPC样式风格的 Web 服务使用方法名称和参数来生成 XML 结构。
- 生成的 WSDL 很难针对模式进行验证。
- 在 RPC 样式中,SOAP 消息发送的元素数量一样多。
- RPC 风格的消息是紧耦合的。
- 在 RPC 样式中,SOAP 消息保留操作名称。
- 在 RPC 风格中,参数作为离散值发送。
让我们看看 RPC 样式生成的 WSDL 文件。
WSDL文件:
在 WSDL 文件中,它没有指定类型的详细信息。
<types/>
对于消息部分,它定义了名称和类型属性。
<message name="getHelloWorldAsString">
<part name="arg0" type="xsd:string"/>
</message>
<message name="getHelloWorldAsStringResponse">
<part name="return" type="xsd:string"/>
</message>
对于soap:body
,它定义了use 和 namespace 属性。
<binding name="HelloWorldImplPortBinding" type="tns:HelloWorld">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
<operation name="getHelloWorldAsString">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal" namespace="http://yiiibai.com/"/>
</input>
<output>
<soap:body use="literal" namespace="http://www.yiibai.com/"/>
</output>
</operation>
</binding>
文档样式
- 文档样式的 Web 服务可以根据预定义的模式进行验证。
- 在文档样式中,SOAP 消息作为单个文档发送。
- 文档样式消息是松耦合的。
- 在 Document 样式中,SOAP 消息丢失了操作名称。
- 在 Document 样式中,参数以 XML 格式发送。
让我们看看 Document 样式生成的 WSDL 文件。
WSDL文件:
在 WSDL 文件中,它指定具有命名空间和 schemaLocation 的类型详细信息。
<types>
<xsd:schema>
<xsd:import namespace="http://www.yiibai.com/" schemaLocation="http://localhost:7779/ws/hello?xsd=1"/>
</xsd:schema>
</types>
对于消息部分,它定义了名称和元素属性。
<message name="getHelloWorldAsString">
<part name="parameters" element="tns:getHelloWorldAsString"/>
</message>
<message name="getHelloWorldAsStringResponse">
<part name="parameters" element="tns:getHelloWorldAsStringResponse"/>
</message>
对于soap:body
,它只定义了使用属性而不是命名空间。
<binding name="HelloWorldImplPortBinding" type="tns:HelloWorld">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="getHelloWorldAsString">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果。
转载请注明:文章转载自 有区别网 [http://www.vsdiffer.com]
本文标题:RPC和Document Web服务的区别
本文链接:https://www.vsdiffer.com/vs/difference-between-rpc-vs-document.html
免责声明:以上内容仅是站长个人看法、理解、学习笔记、总结和研究收藏。不保证其正确性,因使用而带来的风险与本站无关!如本网站内容冒犯了您的权益,请联系站长,邮箱: ,我们核实并会尽快处理。