开发者

Changing WCF service to require SSL

I have a WCF service which was running fine on a http binding. I've tried to update this to use SSL but i am getting the following error:

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

This only occurs when i set the site to "Require SSL" in IIS 7.5 if I uncheck it it works fine.

Here's my config

<system.serviceModel>    
<behaviors&g开发者_如何学Got;
  <serviceBehaviors>
    <behavior name="ServiceBehavior" >
      <dataContractSerializer maxItemsInObjectGraph="2147483646"/>
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="false" />
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<bindings>
  <wsHttpBinding>
    <binding name="wsHttpEndpointBinding">
    </binding>
  </wsHttpBinding>
</bindings>
<services>
  <service behaviorConfiguration="ServiceBehavior" name="WcfService1.Service1">
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost/WcfService1/"/>
      </baseAddresses>
    </host>
    <endpoint address="" binding="wsHttpBinding" bindingConfiguration=""
      name="wsHttpEndpoint" contract="WcfService1.IService1" />
    <endpoint address="mex" binding="mexHttpsBinding" bindingConfiguration=""
      name="MexHttpsBindingEndpoint" contract="IMetadataExchange" />
  </service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

I've tried allsorts and nothing seems to get me there, any help is greatly appreciated!


Modify your binding configuration:

<bindings>
  <wsHttpBinding>
    <binding name="wsHttpEndpointBinding">
      <security mode="Transport" />
    </binding>
  </wsHttpBinding>
</bindings>

And reference that configuration in your endpoint by setting its bindingConfiguration attribute to the name of configuration.

<endpoint address="" binding="wsHttpBinding" 
  bindingConfiguration="wsHttpEndpointBinding"
  name="wsHttpEndpoint" contract="WcfService1.IService1" />

You can also delete the host section with base address because it is not used when hosting in IIS.


In addition to changing the binding configuration settings (as Ladislav mentioned)... Change HTTP in the base address to HTTPS.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜