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 6, 2008 5:16 AM by Xach

thanks, worked a treat

# re: WCF Bindings Needed For HTTPS

Thursday, November 6, 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 9, 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 9, 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 1, 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!

# re: WCF Bindings Needed For HTTPS

Tuesday, December 8, 2009 1:56 AM by _deniska

I'm uisng webHttpBinding to publish clientaccesspolicy.xml in WAS. Trying to apply your solution seemed great, but i'm still thrown on callback with cross-domain error.

Have you any ideas?

# re: WCF Bindings Needed For HTTPS

Tuesday, December 8, 2009 1:58 AM by _deniska

sure... simple http_without_ssl works with webHttpBinding_witout_transport_security

# re: WCF Bindings Needed For HTTPS

Sunday, March 21, 2010 2:04 PM by Zaro

Instead of

<serviceMetadata httpGetEnabled="true" />

you should try

<serviceMetadata httpsGetEnabled="true" />

# re: WCF Bindings Needed For HTTPS

Monday, May 24, 2010 9:43 AM by Rajesh

Very Nice Article. It Solved My Problem.

# re: WCF Bindings Needed For HTTPS

Sunday, June 27, 2010 4:23 PM by Rytis Ūsalis

Thanks, you solved my problem.

# re: WCF Bindings Needed For HTTPS

Monday, June 28, 2010 12:24 AM by Kris Kasias

Your posting (and subsequent comments) were the perfect resolution to getting my WCF Service to respond on both HTTP and HTTPS.  Thanks a million!

# re: WCF Bindings Needed For HTTPS

Thursday, October 14, 2010 4:31 PM by Viral

Thanks very much that solved my problem too.I was having problem while accessing methods of wcf service deployed on https.

always gave http 404 error

# re: WCF Bindings Needed For HTTPS

Tuesday, November 9, 2010 4:34 PM by Mike

Thanks!! This exactly solved my problem. Time and time again, Google searches bring me to your site for answers, and your answers are consistently among the most concise and direct. You know when you're looking for answers, do a search, hit a page, and you get that feeling the page will have the answer you need without a bunch of extraneous crap? I get that feeling when I see your entries.

Thanks again.

# re: WCF Bindings Needed For HTTPS

Monday, March 7, 2011 2:19 PM by Marc

This article saved my life.  Had to push something to production and this was exactly what I was looking for.

Thanks!

# re: WCF Bindings Needed For HTTPS

Monday, March 14, 2011 2:43 PM by sahil

Fixed my issue! Thanks a bunch!

# re: WCF Bindings Needed For HTTPS

Tuesday, April 19, 2011 8:56 AM by Abhilash

Thanks for this article.

I am able to configure the Service. Now I need to build a client with WSDL (NOT svcutil, since I want the client to work with .net 2.0). For testing purpose I am using a local certificate. When I try to browse the service, it is coming without certificate error after installing the certificate in the client machine. (WCF service hosted in IIS and browsed using IE from a machine in the same network).

My problem is when I run the wsdl command, it is thowing an error saying

"- The underlying connection was closed: Could not establish trust relationship

for the SSL/TLS secure channel.

 - The remote certificate is invalid according to the validation procedure.

". What is the way out ? Can you help me ?

Thanks and regards

- Abhilash

# re: WCF Bindings Needed For HTTPS

Wednesday, April 20, 2011 10:38 AM by Brian Lorraine

TO get both HTTP and HTTPS to work

Aleksey Fomichenko  says:

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

I tried this:

<webHttpBinding>

       <binding name="webBindingsecure">

         <security mode="Transport"></security>

       </binding>

     </webHttpBinding>

     <webHttpBinding>

       <binding name="webBinding">

         <security mode="None"></security>

       </binding>

     </webHttpBinding>

and it wouldn't work for either HTTPS or HTTP

You have to do this:

<webHttpBinding>

       <binding name="webBindingsecure">

         <security mode="Transport"></security>

       </binding>

       <binding name="webBinding">

         <security mode="None"></security>

       </binding>

     </webHttpBinding>

Just to clarify: and both HTTP and HTTPS will then both work :)

Trial and error

# re: WCF Bindings Needed For HTTPS

Monday, May 2, 2011 5:32 PM by svj2k

Thanks, Solution worked for me too and saved some time.

# re: WCF Bindings Needed For HTTPS

Tuesday, May 24, 2011 7:29 AM by Shreesh

I am getting following error when i click on any of the services

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

any idea on how to fix this?

# re: WCF Bindings Needed For HTTPS

Thursday, July 7, 2011 6:55 AM by Nitin

Hi

Very thankful. I was hanging from last 16 hours. Now fixed when i used security mode = "transport". After that i got other errors but those were quite simple to fix.

Thanks a lot!

# re: WCF Bindings Needed For HTTPS

Friday, September 16, 2011 7:52 AM by prs

Big thanks to Tim B.  I was using webHttpBinding  and having SOAP based errors. After reading the comments I changes to basic http with Transport mode everything works like charm

[ 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, November 10, 2011 4:45 PM by Kevin

Thanks so much, this quickly got me out of a jam!

# re: WCF Bindings Needed For HTTPS

Tuesday, November 15, 2011 10:51 AM by Steve

thanks!  helped a bunch

# re: WCF Bindings Needed For HTTPS

Thursday, December 1, 2011 7:26 AM by urenjoy

Thanks so much!!! tried different solution but your worked well.

# re: WCF Bindings Needed For HTTPS

Monday, December 12, 2011 3:53 PM by rogergu

Microsoft... please rethink and rewrite all this mess.

# re: WCF Bindings Needed For HTTPS

Tuesday, January 17, 2012 2:32 PM by jrock

may allah bless you with 1000 virgins!!!!

seriously, thanks for the posting.  saved my arse big time and i agree with a former poster about microsoft's obtuse method of handling this process.  very cumbersome.

# re: WCF Bindings Needed For HTTPS

Wednesday, February 1, 2012 3:35 PM by atconway

Ah that pesky Transport mode (or at least it is when I forget to add it). Thank you and makes sense. This is what handles the SSL security for the binding and omitting it certainly would cause an error.

# re: WCF Bindings Needed For HTTPS

Monday, February 13, 2012 9:15 PM by sam

I love you man. save my life

# re: WCF Bindings Needed For HTTPS

Thursday, March 1, 2012 9:50 AM by Chris

Thanks, this saved me a couple of hours of work!

# re: WCF Bindings Needed For HTTPS

Wednesday, May 30, 2012 6:20 AM by johndio

Thank you so much! You saved my time.

# re: WCF Bindings Needed For HTTPS

Thursday, June 7, 2012 5:15 AM by Ash

After 4 years of "Thank you"s - I'd like to add mine. You have saved me a lot of time.

# re: WCF Bindings Needed For HTTPS

Tuesday, July 31, 2012 5:13 AM by chandrakant kadu

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

# re: WCF Bindings Needed For HTTPS

Friday, August 3, 2012 4:51 PM by Eric Shupps

Add me to the "this saved me a ton of time" list.  WCF configuration is a never-ending mystery.  Thanks for clearing this one up!

# re: WCF Bindings Needed For HTTPS

Friday, September 28, 2012 10:34 AM by Chase

Another poor WCF ignorant soul saved, Thanks for this, you saved my day!

# re: WCF Bindings Needed For HTTPS

Monday, November 5, 2012 10:44 AM by Samrat Deb

Thanks, worked like a charm for me...

it saved a lot of time as I spent one whole day trying to figure out the solution.

Your solution saved me :)

Thanks

# re: WCF Bindings Needed For HTTPS

Friday, November 30, 2012 2:21 PM by Word

If you would like to obtain a good deal from this post then

you have to apply such techniques to your won webpage.

# re: WCF Bindings Needed For HTTPS

Monday, December 3, 2012 12:52 PM by Royer

Ahaa, its nice dialogue on the topic of this post here at this weblog, I have read all that, so now me also commenting

at this place.

# re: WCF Bindings Needed For HTTPS

Thursday, December 13, 2012 10:05 PM by Kerr

Ahaa, its fastidious dialogue concerning this article at this

place at this web site, I have read all that, so at this time me also commenting

here.

# re: WCF Bindings Needed For HTTPS

Friday, December 14, 2012 12:16 AM by Carpenter

Wow, incredible blog layout! How long have you been blogging for?

you made blogging look easy. The overall look of your website is

fantastic, as well as the content!

# re: WCF Bindings Needed For HTTPS

Monday, April 15, 2013 4:18 AM by Jaime

Hello, I believe your web site might be having web browser compatibility issues.

When I take a look at your site in Safari, it looks fine however, if opening in I.

E., it has some overlapping issues. I simply wanted to

provide you with a quick heads up! Besides that, excellent blog!

# re: WCF Bindings Needed For HTTPS

Monday, April 15, 2013 4:24 AM by Mahaffey

of course like your website but you have to test the

spelling on several of your posts. Several of them are rife with spelling

problems and I to find it very bothersome to tell the truth

however I'll surely come again again.

# re: WCF Bindings Needed For HTTPS

Monday, April 15, 2013 6:05 AM by Levi

What i don't understood is if truth be told how you're not actually much

more well-appreciated than you may be now. You're very intelligent. You understand thus significantly with regards to this topic, made me in my view consider it from a lot of varied angles. Its like women and men don't seem to be interested until it is something to accomplish

with Woman gaga! Your personal stuffs outstanding. At all times deal with it

up! It would be better if your character was left to go it alone.

Nintendo 3DS was developed and primed to become the successor to the Nintendo DS.

I rented it for a few days and thoroughly enjoyed playing it for a few hours a day, however if I were to buy this game I'd wait for the price to depreciate quite a ways before purchasing.

# re: WCF Bindings Needed For HTTPS

Thursday, April 18, 2013 8:48 AM by Payton

Asking questions are truly good thing if you are not understanding something fully, however this

paragraph provides pleasant understanding even.

# re: WCF Bindings Needed For HTTPS

Sunday, April 21, 2013 7:43 AM by Bobo

It's not my first time to pay a quick visit this web page, i am visiting this web site dailly and obtain good information from here all the time.

# re: WCF Bindings Needed For HTTPS

Monday, April 22, 2013 9:36 AM by Tibbs

I every time spent my half an hour to read this webpage's articles or reviews everyday along with a mug of coffee.

# re: WCF Bindings Needed For HTTPS

Friday, May 10, 2013 4:02 AM by Vandiver

you are truly a excellent webmaster. The website loading pace

is incredible. It kind of feels that you're doing any distinctive trick. In addition, The contents are masterpiece. you've performed a fantastic task on this subject!