WCF客户端代理处理不正确返回SOAP信封 [英] WCF client proxy mishandling returned SOAP envelope

查看:93
本文介绍了WCF客户端代理处理不正确返回SOAP信封的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个RPC编码的PHP Web服务,该服务返回一个带有布尔数据类型的简单肥皂信封.在客户端进行跟踪时,在进入WCF代理之前,肥皂信封如下所示:

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>

但是,当返回值出现在代理服务器的另一端时,它已更改为false.我尝试将xsi:type ="xsd:boolean"添加到OutingVar1,但这无济于事.肥皂信封本身正是客户所期望的,但是由于某种原因,它将无法正确使用它.这与PHP Web服务的设置方式有关还是在WCF代理中?这样简单地设置了PHP Web服务:

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

,该函数以简单的"return true;"结尾.线.这里没什么复杂的.任何想法可能是什么问题吗?

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

带注释的WSDL(删除了琐碎的名称空间并修改了真实的名称空间)看起来像这样:

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!

推荐答案

该解决方案最终处理了名称空间.由于它们没有正确传播,因此我需要将属性elementFormDefault ="qualified"添加到架构中.这迫使前缀出现在每个元素上,这是我让.NET满意的唯一方法.感谢您的帮助.

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.

这篇关于WCF客户端代理处理不正确返回SOAP信封的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆