0
votes

I am trying to host a WCF Service over http and https and using the below config:

<system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_ITestService">
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
                realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
        <binding name="BasicHttpsBinding_ITestService">
          <security mode="Transport">
            <transport clientCredentialType="None" proxyCredentialType="None" />
            <message />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="TestService" behaviorConfiguration="TestServiceBehaviour">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8081/"/>
            <add baseAddress="https://localhost:8083/"/>
          </baseAddresses>
        </host>
        <endpoint address=""
             binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITestService"
             contract="ITestService" name="BasicHttpsBinding_ITestService" />
        <endpoint address=""
             binding="basicHttpBinding" bindingConfiguration="BasicHttpsBinding_ITestService"
             contract="ITestService" name="BasicHttpsBinding_ITestService" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="TestServiceBehaviour">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

But I am getting the following error: Could not find a base address that matches scheme https for the endpoint with binding BasicHttpBinding. Registered base address schemes are [http].

Need a solution for this as I've defined both base address and binding for both http and https.

Thanks.

2

2 Answers

0
votes

try this

<endpoint address=""
          binding="basicHttpBinding" 
          bindingConfiguration="BasicHttpBinding_ITestService"
          contract="ITestService" name="BasicHttpsBinding_ITestService"/>
<endpoint address=""
          binding="basicHttpBinding" 
          bindingConfiguration="BasicHttpsBinding_ITestService"
          contract="ITestService" name="BasicHttpsBinding_ITestService"/>
 <endpoint address="mex" 
         binding="mexHttpsBinding" 
         contract="IMetadataExchange" />
0
votes

I did not enable the https binding on the IIS Server and was trying to host a service using https protocol. Creating a certificate and enabling the https binding on the IIS Server resolved the issue. :)