原文:https://www.yiibai.com/web_service/difference-between-rpc-and-document.html
RPC和文档Web服务之间存在许多差异,它们之间的重要区别如下:
以下是RPC样式Web Service的重要特性:
让我们看一下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://yiibai.com/"/>
</input>
<output>
<soap:body use="literal" namespace="http://yiibai.com/"/>
</output>
</operation>
</binding>
让我们看一下文档样式生成的WSDL文件。
WSDL文件:
在WSDL文件中,它指定具有namespace
和schemaLocation
的类型详细信息。
<types>
<xsd:schema>
<xsd:import namespace="http://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
,它只定义use
属性而不是namespace
。
<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>