Wcf – How to make WCF service https enabled and consume it in silverlight

httpservicesilverlightwcf

I have a silverlight client which currently communicates with WCF service unsecuredly.

1>I want to make WCF service secured.(https enabled)
2>I want to refer secure wcf service in silverlight client.

Can anyone help in configuring service?

Web.config :

<serviceHostingEnvironment aspNetCompatibilityEnabled="true"></serviceHostingEnvironment>

<bindings>
  <basicHttpBinding>
    <binding name="MyBasicHttpBinding" >          
      <security mode="Transport" >
        <transport clientCredentialType="None"/>
      </security>
    </binding>
  </basicHttpBinding>
</bindings>

<services>
  <service behaviorConfiguration="DataService.Service1Behavior"
    name="DataService.Service1">
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="MyBasicHttpBinding"
      contract="DataService.IService1">         
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>     
</services>

<behaviors>
  <serviceBehaviors>
    <behavior name="DataService.Service1Behavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" httpHelpPageEnabled="true" httpsHelpPageEnabled="true" />
    </behavior>      
  </serviceBehaviors>
</behaviors>

I am getting following error message:

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

Best Answer

The main part you need to correct is binding and service behaviour as givn in following configuration

1) At the place of binding="basicHttpBinding" use binding="wsHttpBinding" 2) At the place of binding="mexHttpBinding" use binding="mexHttpsBinding" 3) In service behaviour serviceMetadata httpsGetEnabled="true"

You can find very easy steps to configure WCF on https here

Related Topic