2010-05-18 29 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