Search code examples
.netwcfapp-configwcf-bindingwcf-security

WSHttpBinding and Https problem


I want to use Sessions and SSL at the same time so I set up all the certificates and made sure everything was set up properly on the WCF service. I've tried about everything but I cant seem to get this to work. It throws me a InvalidoperationException saying that the WsHttpBinding can't create secure sessions and that I should use MessageSecurity instead of TransportSecurity.But I want to use Https and not Http so I want to use TransportSecurity. Could Anyone please help me out. Thanks in advance.

App.config for WsHttpBinding:

   <wsHttpBinding>
    <binding name="WSHttpBinding">
     <reliableSession enabled="True" />
     <security mode="Transport">
      <transport clientCredentialType="None"/>
     </security>
    </binding>
   </wsHttpBinding>

Edit: I forgot to mention that the InvalidOperationException Occurs when I try to call ServiceHost.Open() So the Logging will not do much good, but thank you for mentioning it.


Solution

  • I didn't try it but MSDN says:

    To use a reliable session over HTTPS, you must create a custom binding that uses a reliable session and the HTTPS transport.

    Try the custom binding described in the article.

    Edit:

    I checked with Reflector why it doesn't work with WsHttpBinding. WsHttpBinding contains this code when initializing security:

    if (isReliableSession && !this.IsSecureConversationEnabled())
    {
        throw ...
    }
    

    It probably means that WsHttpBinding allows using reliable session over unsecured channel or over channel secured with message security and secure conversation.