Nemir
Nemir

Reputation: 293

c# binding error in WCF

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

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.

Upvotes: 3

Views: 2057

Answers (2)

Nemir
Nemir

Reputation: 293

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>

Upvotes: 1

Rajesh
Rajesh

Reputation: 7886

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)

Upvotes: 0

Related Questions