Publish WCF Service in IIS with support for both HTTP and HTTPS

Posted by Krishnasamy2008 under WCF on 5/11/2012 | Points: 10 | Views : 7466 | Status : [Member] | Replies : 2
Hi Friends,

I have a WCF-Service configured with two endpoints using wsHttpBinding, one for http and the other for https. They use the same address, the endpoints just differ by the used protocol:

<services>
<service name="Test.ClientService">
<endpoint binding="wsHttpBinding" bindingConfiguration="wsBindingConfig" behaviorConfiguration="wsBehaviour" contract="Test.Contracts.IClientService"/>
<endpoint binding="wsHttpBinding" bindingConfiguration="sslWsBindingConfig" behaviorConfiguration="wsBehaviour" contract="Test.Contracts.IClientService"/> </service>
<services>

using the following behaviours and bindings:

<behaviors>
<endpointBehaviors>
<behavior name="wsBehaviour">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="wsBindingConfig">
<security mode="None"/>
</binding>
<binding name="sslWsBindingConfig">
<security mode="Transport"/>
</binding>
</webHttpBinding>
</bindings>

Both endpoints works fine when I have the certificate installed on IIS 6.

When the certificate is not installed in the IIS, the HTTPS-Endpoint certainly won't work. But the HTTP-Endpoint also doesn't work.
It fails with an exception: when I access the service with http://localhost:5034/Test/ClientService.svc
The exception is as below:
Could not find a base address that matches scheme https for the endpoint with binding WebHttpBinding. Registered base address schemes are [http].
which is irritating because I didn't request an HTTPS-URL.
Now when I split the service into two, the HTTP-Access also works on the IIS on which the SSL-Certificate is not installed:

<services>
<service name="Test.ClientServicee"> <endpoint binding="wsHttpBinding" bindingConfiguration="wsBindingConfig" behaviorConfiguration="webBehaviour" contract="Test.Contracts.IClientService"/>
</service>
<service name="Test.ClientService">
<endpoint binding="wsHttpBinding" bindingConfiguration="sslWsBindingConfig" behaviorConfiguration="webBehaviour" contract="Test.Contracts.IClientService"/>
</service>
</services>

The problem now is that the client has to use two different endpoints instead of just changing the protocol. We have a system where the customer can turn on SSL via our Configuration-Tool depending on their security needs. But I don't want to force them to change the web.config of the WCF-Service.I want to access both endpoints protocol http or https simultaneously.Please can anyone guide me how to do.

Thanks ,
Krishna.K




Responses

Posted by: Rajkatie on: 6/23/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
Hi Krishnasamy,

Your requirement may be fullfilled by WCF 4.5 because it support Multiple Authentication. Please refer following link
http://msdn.microsoft.com/en-us/library/dd456789%28v=vs.110%29.aspx

Rajesh Patel
.Net Trainer(MSCD | MCT | MS)
Brainbench (Asp.Net 4.5 and C# 5.0)

Krishnasamy2008, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ovidiu.Tudorache on: 1/6/2015 [Member] Starter | Points: 25

Up
0
Down
Did you find a solution?

Krishnasamy2008, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response