Question

I am getting the following error when trying to access a WCF service.

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

Here's my config

<?xml version="1.0"?>
    <configuration>
      <system.web>
        <compilation debug="true"/>
        <customErrors mode="Off"/>
      </system.web>

      <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <binding name="DefaultHttpBinding"
                     maxBufferSize="655360"
                     maxReceivedMessageSize="655360">
            </binding>
          </basicHttpBinding>
        </bindings>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true">
          <baseAddressPrefixFilters>
            <add prefix="http://MySite.com/MyVirtualDir/"/>
          </baseAddressPrefixFilters>
        </serviceHostingEnvironment>
        <services>
          <service behaviorConfiguration="DefaultBehavior"
                   name="MyWcfService">
            <endpoint address="http://MySite.com/MyVirtualDir/MyWcfService.svc"
                      binding="basicHttpBinding"
                      bindingConfiguration="DefaultHttpBinding"
                      contract="MyNamespace.IMyWcfService" />
            <endpoint address="mex"
                      binding="mexHttpBinding"
                      contract="IMetadataExchange" />
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="DefaultBehavior">
              <serviceMetadata httpGetEnabled="true"
                               policyVersion="Policy15"/>
              <serviceDebug httpHelpPageEnabled="true"
                            includeExceptionDetailInFaults="true"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
    </configuration>

And here's my .scv file

<%@ ServiceHost Language="C#" Debug="true" Service="MyWcfService" Factory="MyWcfServiceHostFactory"%>

To give some more background that may or may not be helpful

  • The service works fine in our DEV environment. This error is only occurring in our TEST and PROD environments. The only discernable difference between environments that i am aware of is that TEST and PROD are using a load balancer.
  • The service is hosted in IIS 5.1 on all environments
  • The service has been written in dot.net 3.5 and is activated by a WebServiceHost factory
  • I have not specified https anywhere in my config file
  • SSL has NOT been enabled in IIS on any of the environments. Anonymous access has been enabled (security implementation will come later on).

Any help would be much appreciated as this is a complete show stopper for our project. I have throurghly searched the web for solutions to this problem, but nothing seems to relate to my my particular set up.

Was it helpful?

Solution

So for me, the fix for this issue was to remove the mex binding as per some of your suggestions. I also removed the servicemetadata section from the DefaultBehavior in config.

This fix only hides the original issue as I still have no idea why the mex binding was registered as https. But I can now consume my web service, even if i can't retrieve the metadata from it - that's not a problem in my case.

Here's the corrected config

<?xml version="1.0"?>
    <configuration>
        <system.web>
            <compilation debug="true"/>
            <customErrors mode="Off"/>
        </system.web>

        <system.serviceModel>
            <bindings>
                <basicHttpBinding>
                    <binding name="DefaultHttpBinding"
                             maxBufferSize="655360"
                             maxReceivedMessageSize="655360">
                    </binding>
                </basicHttpBinding>
            </bindings>
            <serviceHostingEnvironment aspNetCompatibilityEnabled="true">
                <baseAddressPrefixFilters>
                    <add prefix="http://MySite.com/MyVirtualDir/"/>
                </baseAddressPrefixFilters>
            </serviceHostingEnvironment>
            <services>
                <service behaviorConfiguration="DefaultBehavior"
                         name="MyWcfService">
                    <endpoint address="http://MySite.com/MyVirtualDir/MyWcfService.svc"
                              binding="basicHttpBinding"
                              bindingConfiguration="DefaultHttpBinding"
                              contract="MyNamespace.IMyWcfService" />
                </service>
            </services>
            <behaviors>
                <serviceBehaviors>
                    <behavior name="DefaultBehavior">
                        <serviceDebug httpHelpPageEnabled="true"
                                      includeExceptionDetailInFaults="true"/>
                    </behavior>
                </serviceBehaviors>
            </behaviors>
        </system.serviceModel>
    </configuration>

OTHER TIPS

Try enabling tracing on your service to check why things fail in your test/production environment. To enable tracing check this link

Are you sure that the MyWcfServiceHostFactory doesnt have any code related to configuration (i.e. building configuration via c# code)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top