duanbeng8872 2009-07-15 21:30
浏览 62
已采纳

WCF客户端代理错误处理返回SOAP信封

I have a RPC encoded PHP webservice that returns a simple soap envelope with a boolean datatype. When doing the trace on the client side, the soap envelope looks like this right before it goes into the WCF proxy:

<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>

However, when the returned value comes out the other side of the proxy it's been changed to false. I've tried adding an xsi:type="xsd:boolean" to the outgoingVar1, but that doesn't help. The soap envelope itself is exactly what the client should be expecting, but for some reason it won't consume it correctly. Is this something that has to do with the way the PHP web service is set up or is it in the WCF proxy? The PHP web service is simply set up like this:

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();

and the function ends with a simple 'return true;' line. Nothing complicated here. Any ideas what the problem may be?

The annotated WSDL (removed trivial namespaces and modified the real ones) looks like this:

<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>

This should be enough to see how things are declared...let me know if you need anything else clarified. Thanks for your help!

  • 写回答

2条回答 默认 最新

  • doutun1875 2009-09-09 21:05
    关注

    The solution ended up dealing with the namespaces. Since they weren't propagating correctly, I needed to add the attribute elementFormDefault="qualified" to the schema. That forces the prefix to be present on every element, which is the only way I could make .NET happy. Thanks for your help on this.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch