2010-05-18 93 views
4

我正在使用由我们的供应商开发的一个Java Web服务,我真的没有任何控制权。我写了一个客户端应用程序调用它的WCF路由器,路由器将消息发送到Java Web服务并将数据返回给客户端。WCF MustUnderstand头文件不被理解

我遇到的问题是,我成功地能够从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> 

如果我用我越来越

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

的textMessageEncoding如果我使用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> 
    <endpoint address="http://JavaWS/EmployeeService" binding="wsHttpBinding" 
     bindingConfiguration="wsHttp" contract="EmployeeService.IEmployeeService" 
     name="client" behaviorConfiguration="clientBehavior"> 
    <headers>   
    </headers> 
    </endpoint> 
</client> 

非常感谢你的帮助。

由于提前, Raghu

回答

1

这个问题是在.NET 4.0中使用RoutingService解决。

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

+0

那么,为什么会发生这种情况呢?你能否以某种方式改变消息中mustunderstand头的价值? – 2013-09-02 13:01:02