【发布时间】:2009-07-15 21:30:53
【问题描述】:
我有一个 RPC 编码的 PHP 网络服务,它返回一个带有布尔数据类型的简单肥皂信封。在客户端进行跟踪时,soap 信封在进入 WCF 代理之前看起来像这样:
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://sample.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org
/soap/encoding/">
<SOAP-ENV:Body>
<ns1:ServiceMessageResponse>
<outgoingVar1>true</outgoingVar1>
</ns1:ServiceMessageResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
但是,当返回值从代理的另一端传出时,它已更改为 false。我尝试将 xsi:type="xsd:boolean" 添加到传出Var1,但这没有帮助。肥皂信封本身正是客户所期望的,但由于某种原因,它不能正确使用它。这与 PHP Web 服务的设置方式有关还是在 WCF 代理中? PHP web 服务的简单设置如下:
ini_set('soap.wsdl_cache_enabled', '0');
ini_set('soap.wsdl_cache_ttl', '0');
$soapServer = new SoapServer('wsdl/sample.wsdl', array('soap_version' => SOAP_1_1));
$soapServer->addFunction('Service');
$soapServer->handle();
并且函数以简单的'return true;'结束线。这里没有什么复杂的。任何想法可能是什么问题?
带注释的 WSDL(删除了琐碎的命名空间并修改了真实的命名空间)如下所示:
<wsdl:definitions name="IJLSoapResponse" targetNamespace="http://casey.com"
tns="http://casey.com" xmlns:samp="http://sample.com" ...>
<wsdl:types>
<xsd:schema targetNamespace="http://casey.com" ...>
<xsd:element name="incomingVar1" type="xsd:string" nillable="true"/>
<xsd:element name="incomingVar2" type="xsd:string" nillable="true"/>
</xsd:schema>
<xsd:schema targetNamespace="http://sample.com" ...>
<xsd:element name="outgoingVar1" type="xsd:boolean" nillable="true"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="ServiceInput">
<wsdl:part name="incomingVar1" element="tns:incomingVar1"/>
<wsdl:part name="incomingVar2" element="tns:incomingVar2"/>
</wsdl:message>
<wsdl:message name="ServiceOutput">
<wsdl:part name="outgoingVar1" element="samp:outgoingVar1"/>
</wsdl:message>
<wsdl:portType name="ServicePortType">
<wsdl:operation name="ServiceMessage" parameterOrder="incomingVar1 incomingVar2">
<wsdl:input name="ServiceMessageRequest" message="tns:ServiceInput"/>
<wsdl:output name="ServiceMessageResponse" message="tns:ServiceOutput"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ServiceBinding" type="tns:ServicePortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="ServiceMessage">
<soap:operation soapAction="http://casey.com/soap/Service"/>
<wsdl:input name="ServiceMessageRequest">
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://casey.com"/>
</wsdl:input>
<wsdl:output name="ServiceMessageResponse">
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://sample.com"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ServiceService">
<wsdl:port name="ServicePort" binding="tns:ServiceBinding">
<soap:address location="http://casey.com/soap/Service"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
这应该足以了解事物是如何声明的...如果您需要澄清其他任何内容,请告诉我。感谢您的帮助!
【问题讨论】:
-
你在 WCF 方面的合同是什么样的?
-
@caseycrites:我需要查看一些 WCF 代码才能将 2 和 2 放在一起。我会把这个转给其他一些可能的人。
-
WCF 合同是合作伙伴的代码,所以我不认为我可以得到它......或者在这里发布它。对不起...
-
关于发布 WSDL 的建议。不要删除琐碎的命名空间——这意味着我必须将它们添加回来才能使用它。不要放“...”或任何其他无效的 XML。如果你想要这样的东西,请使用评论。
-
你在这方面有所收获吗?