I have a WCF Service with wsHttpBindings and SSL enabled, but I\'d like to enable WCF sessions.
After changing SessionMode to required
SessionMode:
By default, WSHttpBinding only allows security sessions. It is a concept of WCF and is not linked to Transport. A security session is not a session over https, but a session with mutual authentication. This is achieved by adding message security.
Based upon your service, you should apply this config
On clientside, here is a simple unit test
[TestMethod]
public void TestSecuritySession()
{
//remove this is certificate is valid
ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback((sender, certificate, chain, sslPolicyErrors) => { return true; });
var binding = new WSHttpBinding();
binding.Security = new WSHttpSecurity() { Mode = SecurityMode.TransportWithMessageCredential};
ChannelFactory Factory = new ChannelFactory(binding, new EndpointAddress("https://localhost/TestService.svc"));
Factory.Open();
var channel = Factory.CreateChannel();
//call service here
(channel as IClientChannel).Close();
Factory.Close();
}