3

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.

Nemir
  • 283
  • 1
  • 3
  • 9
  • you are obviously aware of it already, but the error *really* suggests that https is required one way or another. But since the error is related to the metadata exchange you could try to check if disabling that lets you access the service and then try to eradicate the meta data problem later on. Perhaps you should also check if there are nay inherited settings for the meta date exchange. – faester Nov 18 '11 at 12:59
  • if you think the load balancer could be causing an issue, then can you organise a test where it is by-passed? – wal Nov 18 '11 at 14:05
  • can you paste the client config too? – wal Nov 18 '11 at 14:06
  • I did try bypassing load balancer and connecting directly to both the nodes but got the same error. Also, this is the first WCF service to be hosted (currently all other web services are asmx) so I don't think there are any other mex binding configurations that are being inherited from. – Nemir Nov 18 '11 at 14:19
  • BTW. Thanks for your speedy and helpful responses. Unfortunately, I have to go through a long drawn out change control process to deploy to the offending environments and I don't have any direct access to them either so i won't be able to test your suggestions as speedily. I will try disabling the mex binding next. – Nemir Nov 18 '11 at 14:22
  • Here's my client config. Sorry, had to remove some bits of it to get it to fit in the comment. For now i've been simply entering the url into a browser as the client is a silverlight 3 app requiring client side asyn operation contracts and I wanter to eliminate that being the cause of the issue. – Nemir Nov 18 '11 at 14:34

2 Answers2

1

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>
Nemir
  • 283
  • 1
  • 3
  • 9
0

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)

Rajesh
  • 7,766
  • 5
  • 22
  • 35
  • Unfortunately tracing did not provide any more detail. The Host factory does add two behaviours, one to wire up Ioc and DI and the other to change FaultExceptions to HttpStatusCode200 (required to get the fault details passed back to a Silverlight client) – Nemir Nov 22 '11 at 13:51
  • Is your loadbalancer configured to establish the security using only https and not http. Worth trying to divert the traffic directly to the test box rather than the load balancer and then check if you still get the exception. – Rajesh Nov 22 '11 at 14:05
  • Are you trying to access your web service using https rather than http. If that is the case your service has been configured for http and not for https. If your scenario is that the load balancer terminates the SSL then that should work without any problem. – Rajesh Nov 22 '11 at 15:04
  • It's more the other way round, I'm trying to use http, not https. The infrastructure guys have assured me that SSL is not enabled in that environent, either on the load balancer or any of the nodes. I've already tried diverting directly to the test box and got the same error. – Nemir Nov 22 '11 at 15:46
  • Can you remove the mex endpoint in your test evironment and check if you can access the web service or not. And are you using IIS to hose the service? – Rajesh Nov 22 '11 at 15:49