我正在尝试使用 WCF 使用 Soap 1.1 Web 服务。在从 wsdl 定义中使用 svcutil 生成代理后,我发现所有响应都为空。
该服务似乎使用 RPC 文字,因此 WCF 回退到使用XmlSerializer
. 这是 wsdl 的定义:
<wsdl:definitions xmlns:typens="http://www.myservice.es/Schemas" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://www.myservice.es/Schemas">
<wsdl:types>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.myservice.es/Schemas">
<xsd:include schemaLocation="../xsd/myservicetypes.xsd"/>
</xsd:schema>
</wsdl:types>
<message name="serviceRequest"/>
<message name="serviceResponse">
<part name="serviceReturn" type="typens:DateTimeResponse"/>
</message>
<portType name="QueryServiceDateTimePort">
<operation name="QueryServiceDateTime">
<input message="typens:serviceRequest"/>
<output message="typens:serviceResponse"/>
</operation>
</portType>
<binding name="QueryServiceDateTimeBinding" type="typens:QueryServiceDateTimePort">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="QueryServiceDateTime">
<soap:operation soapAction="urn:QueryServiceDateTime"/>
<input>
<soap:body use="literal" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://www.myservice.es/Schemas"/>
</input>
<output>
<soap:body use="literal" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://www.myservice.es/Schemas"/>
</output>
</operation>
</binding>
<service name="QueryServiceDateTimeService">
<port name="QueryServiceDateTimePort" binding="typens:QueryServiceDateTimeBinding">
<soap:address location="https://www.tests.com"/>
</port>
</service>
但是,服务返回此响应:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<serviceResponse>
<serviceReturn>
<DateTime v="2013-04-20T01:13:22.001" xmlns="http://www.myservice.es/Schemas"/>
</serviceReturn>
</serviceResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
WCF 和 SoapUI 都期望元素名为QueryServiceDateTimeResponse
instead 或 before serviceResponse
,因此它们无法反序列化或验证响应。
我怎样才能让 WCF 协调这个响应并反序列化它?我可以标记代理以打开该元素吗?
我应该注意,我不能在这种情况下使用 MessageContract,因为它与 RPC - Literal 不兼容。