Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF Service not working from Visual Studio due to SSL

I've recently added HTTPS to my WCF service, which is working correctly on my development IIS server, for both HTTP and HTTPS. However, now when I try to run using Visual Studio (localhost), I'm getting this error when trying to hit the service:

Exception: System.InvalidOperationException
Description: Could not find a base address that matches scheme https for the endpoint    with binding WebHttpBinding. Registered base address schemes are [http]. 
Timestamp: 5/15/2013 4:23:04 PM
Client IP Address/DNS Name: ::1 - ::1

at System.ServiceModel.ServiceHostBase.MakeAbsoluteUri(Uri relativeOrAbsoluteUri,    Binding binding, UriSchemeKeyedCollection baseAddresses)
at System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase host, ServiceDescription description, ServiceElement serviceElement, Action`1 addBaseAddress, Boolean skipHost)

Here is my web.config:

<system.serviceModel>
  <bindings>
    <webHttpBinding>
      <binding name="sslBinding">
        <security mode="Transport">
          <transport clientCredentialType="None" proxyCredentialType="None" />
        </security>
      </binding>
    </webHttpBinding>
  </bindings>
  <services>
    <service behaviorConfiguration="ServiceBehavior" name="HistoryService">
      <endpoint behaviorConfiguration="webHttp" binding="webHttpBinding" contract="IHistoryService" />
      <endpoint binding="webHttpBinding" contract="IHistoryService" behaviorConfiguration="webHttp" bindingConfiguration="sslBinding" />
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    </service>
  </services>
  <behaviors>
    <endpointBehaviors>
      <behavior name="webHttp">
        <webHttp />
      </behavior>
    </endpointBehaviors>
    <serviceBehaviors>
      <behavior name="ServiceBehavior">
        <serviceMetadata httpGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="false" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>

It would be very nice if I could continue to develop using Visual Studio's dev server. Is there something I need to enable with the Visual Studio Development Server for it to work with HTTPS? Or is there something I can modify in my web.config to make it play nicely?

like image 584
Joe Korolewicz Avatar asked Nov 30 '25 23:11

Joe Korolewicz


1 Answers

The built-in web server in visual studio does not support SSL. Here's a nice tutorial on using IIS Express. I use Microsoft WebMatrix which makes setting up sites using IIS Express simple.

http://www.hanselman.com/blog/WorkingWithSSLAtDevelopmentTimeIsEasierWithIISExpress.aspx

like image 142
Tyler Wilson Avatar answered Dec 02 '25 13:12

Tyler Wilson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!