Configuring a WCF Service to Run Via HTTPS
Yesterday I wrote about how to wire up jQuery UI’s AutoComplete add-in to a WCF Service to create an autocomplete search/navigation control. Today I deployed the resulting code to production but initially had some trouble getting things to work. The only real difference between the two environments is that in production everything goes through HTTPS/SSL, so I figured that had to be the culprit. A bit of searching led to this blog post describing WCF Bindings Needed for HTTPS. I pretty much followed its advice exactly and things worked immediately. Here’s my code:
1: <system.serviceModel>
2: <behaviors>
3: <endpointBehaviors>
4: <behavior name="Web.WebServices.AccountServiceAspNetAjaxBehavior">
5: <enableWebScript />
6: </behavior>
7: </endpointBehaviors>
8: </behaviors>
9: <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
10: multipleSiteBindingsEnabled="true" />
11: <services>
12: <service name="Web.WebServices.AccountService">
13: <endpoint address=""
14: behaviorConfiguration="Web.WebServices.AccountServiceAspNetAjaxBehavior"
15: binding="webHttpBinding"
16: contract="Web.WebServices.AccountService"
17: bindingConfiguration="webBinding" />
18: </service>
19: </services>
20: <bindings>
21: <webHttpBinding>
22: <binding name="webBinding">
23: <security mode="Transport"></security>
24: </binding>
25: </webHttpBinding>
26: </bindings>
27: </system.serviceModel>
The new addition is on line 17, which references the new <bindings /> section on lines 20-26. Hope this helps!