gpt4 book ai didi

wcf - 启用可靠 session 会导致异常,该异常会讨论契约(Contract)过滤器不匹配

转载 作者:行者123 更新时间:2023-12-02 00:05:36 25 4
gpt4 key购买 nike

上下文

我正在玩 WCF 配置,试图启用可靠的 session 。

当禁用可靠 session 时,一切正常,客户端可以成功连接到服务器。我一放 enabled="true"<reliableSession>在服务的Web.config和客户端的App.config中,当客户端尝试打开连接时抛出以下异常:

The message with Action 'http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequence' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).

Stack Overflow 上有很多关于此异常的问题,但似乎没有一个答案适用。例如,我检查了 receiveTimeout and inactivityTimeout are the same , 即 context mode is PerSession both service and client-side

这是踪迹。你会在下面找到我的配置。 它有什么问题?

跟踪

enter image description here

  • 红色的异常(exception)是我上面引用的那个。
  • 刚刚收到的消息是CreateSequence .
  • 异常发生后立即发送的消息是addressing/fault消息,旨在将异常传播给客户端。

服务端配置

<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<bindings>
<netTcpBinding>
<binding name="netTcpEndpoint" sendTimeout="00:10:00" receiveTimeout="00:10:00">
<reliableSession ordered="true" enabled="true" inactivityTimeout="00:10:00" />
<security mode="Message">
<message clientCredentialType="None" />
</security>
</binding>
</netTcpBinding>
</bindings>
<services>
<service behaviorConfiguration="DebugOrientedBehavior" name="Demo.PipeService">
<endpoint address="Default.svc" binding="netHttpBinding"
name="TransportLayerServiceEndpoint" contract="Demo2.IPipeService" />
<host>
<baseAddresses>
<add baseAddress="http://[removed the public URI of the service]/Default.svc" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="DebugOrientedBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>

客户端配置

<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="netTcpEndpoint" sendTimeout="00:10:00" receiveTimeout="00:10:00">
<reliableSession ordered="true" inactivityTimeout="00:10:00" />
<security>
<message clientCredentialType="None" />
</security>
</binding>
</netTcpBinding>
<netHttpBinding>
<binding name="TransportLayerServiceEndpoint">
<reliableSession ordered="true" enabled="true" />
<webSocketSettings transportUsage="Always" />
</binding>
</netHttpBinding>
</bindings>
<client>
<endpoint address="ws://[removed the public URI of the service]/Default.svc/Default.svc"
binding="netHttpBinding" bindingConfiguration="TransportLayerServiceEndpoint"
contract="PipeServiceReference.IPipeService" name="TransportLayerServiceEndpoint" />
</client>
</system.serviceModel>

最佳答案

在服务器配置 enspoint 添加:

bindingConfiguration="netTcpEndpoint"

当前绑定(bind)配置未附加到端点,因此使用默认的 net tcp 设置。在您进行更改之前它很好,但现在不行了。

关于wcf - 启用可靠 session 会导致异常,该异常会讨论契约(Contract)过滤器不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18586550/

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