how to enable WCF Session with wsHttpBidning with Transport only Security

Mubashar picture Mubashar · Apr 16, 2010 · Viewed 16.8k times · Source

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

I have set

[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]

But when i set

SessionMode=SessionMode.Required

on service contract it says

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

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>

please help me with this

Answer

marc_s picture marc_s · Apr 16, 2010

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

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>