Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF Exception: Could not find a base address that matches scheme http for the endpoint

I'm trying to host a WCF web service on a separate Website in IIS with https at 443 as the only binding.

The following configurations works well when I use it in a website which uses both the bindings (http(80) / https(443)). If I remove the http binding, it starts throwing the following error.

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

How do I make it work in an IIS website with https binding only?

  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="defaultBasicHttpBinding">
          <security mode="Transport">
            <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
            <message clientCredentialType="Certificate" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost/ERPService/retailPayment.svc"
                binding="basicHttpBinding" bindingConfiguration="defaultBasicHttpBinding"
                contract="RetailPaymentService.RetailPayment.SVRetailPaymentService" name="EnterpriseRetailPayment" />
    </client>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MyServiceTypeBehaviors">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
        <behavior>
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="MyEndPointBehavior">
          <!--<SchemaValidator enabled="true"/>-->
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <services>
      <service name="SettlementSalesCollection.SaleItemService" behaviorConfiguration="MyServiceTypeBehaviors">
        <endpoint behaviorConfiguration="MyEndPointBehavior" binding="basicHttpBinding"
                  name="SettlementSalesCollection"
                  contract="SettlementSalesCollection.CITransactionSettlementListenerService" />
        <endpoint name="mexEndpoint" contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
      </service>
    </services>
    <extensions>
      <behaviorExtensions>
        <add name="SchemaValidator"
             type="SettlementSalesCollection.SchemaValidation.SchemaValidationBehavior+CustomBehaviorSection, SettlementSalesCollectionService, Version=1.0.0.0, Culture=neutral" />
      </behaviorExtensions>
    </extensions>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
like image 203
RealWillyWoka Avatar asked Nov 11 '13 23:11

RealWillyWoka


3 Answers

Your configuration should look similar to that. You may have to change <transport clientCredentialType="None" proxyCredentialType="None" /> depending on your needs for authentication. The config below doesn't require any authentication.

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

<services>
    <service name="XXX">
        <endpoint
            name="AAA"
            address=""
            binding="basicHttpBinding"
            bindingConfiguration="basicHttpBindingConfiguration"
            contract="YourContract" />
    </service>
<services>

That will allow a WCF service with basicHttpBinding to use HTTPS.

like image 130
Szymon Avatar answered Nov 11 '22 10:11

Szymon


In my case this fixed the issue

  1. Go to Project Properties by clicking F4 on the project name
  2. Set SSLEnabled = true

Project Properties Image

like image 34
Ketaki More Avatar answered Nov 11 '22 09:11

Ketaki More


You can get this if you ONLY configure https as a site binding inside IIS.

You need to add http(80) as well as https(443) - at least I did :-)

like image 12
Simon_Weaver Avatar answered Nov 11 '22 11:11

Simon_Weaver