【问题标题】:WCF MustUnderstand headers are not understoodWCF MustUnderstand 标头不被理解
【发布时间】:2011-02-20 16:44:37
【问题描述】:

我正在使用由我们的供应商之一开发的 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>
  <endpoint address="http://JavaWS/EmployeeService" binding="wsHttpBinding"
      bindingConfiguration="wsHttp" contract="EmployeeService.IEmployeeService"
      name="client" behaviorConfiguration="clientBehavior">
    <headers>          
    </headers>
  </endpoint>
</client>

非常感谢您的帮助。

提前致谢, 拉古

【问题讨论】:

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


    【解决方案1】:

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

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

    【讨论】:

    • 那么为什么会这样呢?您是否能够以某种方式更改邮件中 mustunderstand 标头的值?
    猜你喜欢
    • 2011-10-04
    • 2011-05-21
    • 1970-01-01
    • 2012-04-12
    • 2011-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多