如何启用WCF会议与wsHttpBidning与交通运输仅安全交通运输、会议、安全、WCF

2023-09-02 10:28:20 作者:负尽天下人

我目前部署basicHttpBindings和SSL WCF服务启用。但现在我需要启用WCF会话(不是ASP会话),所以我感动的服务wsHttpBidnings但未启用会话

I have a WCF Service currently deployed with basicHttpBindings and SSL enabled. But now i need to enable wcf sessions(not asp sessions) so i moved service to wsHttpBidnings but sessions are not enabled

我已经设置

[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]

但是,当我设置

But when i set

SessionMode=SessionMode.Required

在服务合同,它说

合同需要会话,但绑定   WsHttpBinding的不支持或   未正确配置为支持   吧。

Contract requires Session, but Binding 'WSHttpBinding' doesn't support it or isn't configured properly to support it.

以下是WsHttpBinding的定义

following is the definition of WSHttpBinding

<wsHttpBinding>
    <binding name="wsHttpBinding">
      <readerQuotas maxStringContentLength="10240" />
      <reliableSession enabled="false" />
      <security mode="Transport">
        <transport clientCredentialType="None">
          <extendedProtectionPolicy policyEnforcement="Never" />
        </transport>
      </security>
    </binding>
  </wsHttpBinding>

请帮我这个

推荐答案

如果你想会与的wsHttpBinding,你必须使用任何可靠的消息,或安全会话。

If you want "sessions" with wsHttpBinding, you have to use either reliable messaging, or the security sessions.

要启用的wsHttpBinding会话之前,需要可靠的消息,而对于这一点,你需要更改设置可靠的会话(看起来像这样的标记&LT;的ReliableSession /&GT; )启用 - 让您的新的配置是这样的:

To enable sessions on wsHttpBinding, you need reliable messaging, and for that, you need to change the setting for reliable session (the tag that looks like this <reliableSession/>) to be enabled - so your new config would look like this:

<wsHttpBinding>
    <binding name="wsHttpBinding">
      <readerQuotas maxStringContentLength="10240" />
      <reliableSession enabled="true" />
      <security mode="Transport">
        <transport clientCredentialType="None">
          <extendedProtectionPolicy policyEnforcement="Never" />
        </transport>
      </security>
    </binding>
  </wsHttpBinding>