WCF MustUnderstand标头不被理解

时间:2010-05-18 01:38:53

标签: wcf web-services c#-3.0 wcf-binding

我正在使用由我们的供应商开发的Java Web服务,我真的无法控制它。我编写了一个客户端应用程序调用它的WCF路由器,路由器将消息发送到Java Web服务并将数据返回给客户端。

我遇到的问题是,我成功地能够从WCF路由器调用Java Web服务,但是,我收到了以下异常。

路由器配置文件如下:

<customBinding>
    <binding name="SimpleWSPortBinding">
      <!--<reliableSession maxPendingChannels="4" maxRetryCount="8" ordered="true" />-->
      <!--<mtomMessageEncoding messageVersion ="Soap12WSAddressing10" ></mtomMessageEncoding>-->
      <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
      messageVersion="Soap12WSAddressing10" writeEncoding="utf-8" />

      <httpTransport manualAddressing="false" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                                      allowCookies="false" authenticationScheme="Anonymous" bypassProxyOnLocal="true" keepAliveEnabled="true"
                                      maxBufferSize="65536" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"/>
    </binding>
  </customBinding>

测试客户端配置文件

<customBinding>
            <binding name="DocumentRepository_Binding_Soap12">
              <!--<reliableSession maxPendingChannels="4" maxRetryCount="8" ordered="true" />-->
              <!--<mtomMessageEncoding messageVersion ="Soap12WSAddressing10" ></mtomMessageEncoding>-->

              <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
                    messageVersion="Soap12WSAddressing10" writeEncoding="utf-8">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                </textMessageEncoding>

                <httpTransport manualAddressing="false" maxBufferPoolSize="524288"
                    maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
                    bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
                    realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
                    useDefaultWebProxy="true" />
            </binding>
        </customBinding>

如果我使用textMessageEncoding我正在

<soap:Text xml:lang="en">MustUnderstand headers: [{http://www.w3.org/2005/08/addressing}To, {http://www.w3.org/2005/08/addressing}Action] are not understood.</soap:Text>     

如果我使用mtomMessageEncoding,我正在

The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.

我的路由器类如下:

 [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple, AddressFilterMode = AddressFilterMode.Any, ValidateMustUnderstand = false)]
public class EmployeeService : IEmployeeService
{
    public System.ServiceModel.Channels.Message ProcessMessage(System.ServiceModel.Channels.Message requestMessage)
    {

        ChannelFactory<IEmployeeService> factory = new ChannelFactory<IEmployeeService>("client");

        factory.Endpoint.Behaviors.Add(new MustUnderstandBehavior(false));

        IEmployeeService proxy = factory.CreateChannel();

        Message responseMessage = proxy.ProcessMessage(requestMessage);

        return responseMessage;
    }
}

ChannelFactory下面代码中的“client”在配置文件中定义为:

 <client>
  <endpoint address="http://JavaWS/EmployeeService" binding="wsHttpBinding"
      bindingConfiguration="wsHttp" contract="EmployeeService.IEmployeeService"
      name="client" behaviorConfiguration="clientBehavior">
    <headers>          
    </headers>
  </endpoint>
</client>

非常感谢您的帮助。

提前致谢, Raghu

1 个答案:

答案 0 :(得分:1)

使用.NET 4.0中的RoutingService解决了此问题。

我仍然无法在.NET 3.5中解决此问题