gpt4 book ai didi

无法理解 WCF MustUnderstand header

转载 作者:行者123 更新时间:2023-12-01 05:45:08 35 4
gpt4 key购买 nike

我正在使用由我们的供应商之一开发的 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>

真的很感谢你的帮助。

提前致谢,
拉古

最佳答案

此问题已在 .NET 4.0 中使用 RoutingService 解决。

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

关于无法理解 WCF MustUnderstand header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2854092/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com