Wednesday, February 20, 2008 3:27 PM srkirkland

WCF Bindings Needed For HTTPS

I just finished writing my first production WCF application, which worked very well until I deployed it to our production environment.  All of a sudden none of the WCF calls would work, and I would get a JavaScript "TestService is not defined" error.  When I look inside the JS service reference (in debug mode), I got the following error:

Could not find a base address that matches scheme http for the endpoint with binding WebHttpBinding. Registered base address schemes are [https]

So apparently my WCF service registered itself as HTTPS (since it is over SSL), but my binding was only configured for HTTP.  The solution is to define a custom binding inside your Web.Config file and set the security mode to "Transport".  Then you just need to use the bindingConfiguration property inside your endpoint definition to point to your custom binding.  The entire HTTPS-enabled system.serviceModel section is below:

<system.serviceModel>
<behaviors>    
 <endpointBehaviors>
  <behavior name="TestServiceAspNetAjaxBehavior">
   <enableWebScript />
  </behavior>
 </endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
 <service name="TestService">
  <endpoint address="" behaviorConfiguration="TestServiceAspNetAjaxBehavior"
   binding="webHttpBinding" bindingConfiguration="webBinding" contract="TestService" />
 </service>
</services>
 <bindings>
   <webHttpBinding>
     <binding name="webBinding">
       <security mode="Transport">
       </security>
     </binding>
   </webHttpBinding>
 </bindings>
</system.serviceModel>

Hopefully this will help someone who has the same problem.

Filed under: , , ,

Comments

# re: WCF Bindings Needed For HTTPS

Tuesday, May 20, 2008 2:37 PM by rams

Thank you, thank you, thank you.

I was trying to fix the same issue with my WCF enabled web app and your solution helped me address the issue. A google search of "asp.net ajax wcf https" yielded your entry.

Thanks again!!

# re: WCF Bindings Needed For HTTPS

Wednesday, May 21, 2008 11:48 AM by bu

I came across the same problem, and found your solution to be helpful.  Thanks!

# re: WCF Bindings Needed For HTTPS

Thursday, June 12, 2008 7:22 PM by James

I was a bit worried when I found my service would work with ssl off and then I'd get 404/500 errors in production when I turned ssl on - this fixed my problem perfectly!  

Thanks very much :-)

# re: WCF Bindings Needed For HTTPS

Wednesday, June 25, 2008 3:32 AM by Bharath

This detail is good but am facing similar kind of issue using wsHttpBinding, any detail on service configuration entries to host WCF service using SSL would be helpful

# re: WCF Bindings Needed For HTTPS

Thursday, November 06, 2008 5:16 AM by Xach

thanks, worked a treat

# re: WCF Bindings Needed For HTTPS

Thursday, November 06, 2008 9:46 AM by Abhijit

Worked beautifully. Thanks a ton.

Now what if I want to keep both configurations active - one for Http & one for Https? Do I define 2 bindings & 2 endpoints? For Http the security mode would be "None" & for Https "Transport". The only difference between the 2 endpoint elements' attributes would be the 2 binding types. Am I on the right track?

# re: WCF Bindings Needed For HTTPS

Monday, February 09, 2009 11:05 PM by Aleksey Fomichenko

This solution works like a charm in the HTTPS.

However, I am also interested in figuring out how to host the same webservice in both HTTP and HTTPS.

# re: WCF Bindings Needed For HTTPS

Monday, February 09, 2009 11:44 PM by Aleksey Fomichenko

It turns out to be a very simple task to run the same service in both, HTTP and HTTPS:

- Add new webHttpBinding and set its security mode to "None"

- Add a new <endpoint> and point to the new webHttpBinding

# re: WCF Bindings Needed For HTTPS

Friday, April 24, 2009 12:33 PM by Tim B.

Such a beautiful article.

Just one note: after 3 hours we realized that webHttpBinding is not suitable for regular SOAP-based clients (one has to watch these bindings :) and we acknowledge that this is ASP.NET-centric blog). We switched webHttpBinding to basicHttpBinding and our SOAP-based clients were able to parse the generated WSDL and to consume the web service.

# re: WCF Bindings Needed For HTTPS

Thursday, July 23, 2009 12:42 PM by Arturo

Thanks for this post, it solved my problem

# re: WCF Bindings Needed For HTTPS

Saturday, August 01, 2009 2:40 AM by krish

Hey I am facing the same issue.

My  problem is i have to host wcf service in http and https

I am using basichttpbinding but i am getting 500,404 errors for https.

how do we know where the problem  is?

# re: WCF Bindings Needed For HTTPS

Friday, August 14, 2009 5:58 PM by Jay

You saved me with this solution.  Thanks!

# MySQL Webservice - .NET Web und Kommunikation @ tutorials.de: Forum, Tutorial, Anleitung, Schulung &amp; Hilfe

Pingback from  MySQL Webservice - .NET Web und Kommunikation @ tutorials.de: Forum, Tutorial, Anleitung, Schulung &amp; Hilfe

Leave a Comment

(required) 
(required) 
(optional)
(required)