I wanted to host a WCF service in IIS over HTTPS (i.e. using SSL). I already had a service host setup in IIS with a mex endpoint configured for HTTP. So, I configured the host site to use SSL but when I browsed to the service in a web browser I got the following error:
“Could not find a base address that matches scheme http for the endpoint binding MetadataExchangeHttpBinding…”
To change the service to use HTTPS I hade to make a couple of changes.
- Set the metadata exchange endpoint to use the mexHttpsBinding (not the mexHttpBinding).
- Modify the service behaviour to enable getting metadata over HTTPS (httpsGetEnabled).
- Changed the service base address to use HTTPS.
<system.serviceModel>
<services>
<service behaviorConfiguration="ServiceBehavior" name="Service.Service">
...
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="https://www.domaingoeshere.com/" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
...
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
...
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
NB: Don't forget that existing clients will have to update their service references.