tags:

views:

483

answers:

2

Hi all, I'm seeing the following error coming from WCF when trying to hit my REST WCF service on IIS 6.0:

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

My web.config looks like:

<system.serviceModel>
<serviceHostingEnvironment>
  <baseAddressPrefixFilters>
    <!--LOCAL-->
    <add prefix="http://localhost/CustomTrackingService/CustomTrackingService.svc"/&gt;
    <!--TEST-->
    <!--<add prefix="http://mytestserver/CustomTrackingService/CustomTrackingService.svc"/&gt;--&gt;
  </baseAddressPrefixFilters>
</serviceHostingEnvironment>
<services>
  <service name="MyService.CustomTrackingService">
    <endpoint 
      address="MyAction" 
      binding="webHttpBinding" 
      contract="MyContract.ICustomTrackingService" 
      behaviorConfiguration="RestBehavior" />
  </service>
</services>
<behaviors>
  <endpointBehaviors>
    <behavior name="RestBehavior">
      <webHttp />
    </behavior>
  </endpointBehaviors>
</behaviors>

This works fine on my test server and works fine locally if I let Casini grab it (change base address prefix localhost/CustomTrackingService to localhost:1234/). I cannot remember what causes this to occur and my Google-fu is not producing useful results. Any ideas?

A: 

Why are you using a base address prefix + an unrelated value in endpoint@address if you're hosting in IIS?

tomasr
The end result is to have my URL read as http://localhost/CustomTrackingService/CustomTrackingService.svc/MyAction/MyNoun for the REST service. If there is a better way to do this I am happy to listen.
JHubSharp
+1  A: 

So looks like the problem is that locally i was trying to use a relative address with no base address defined. This worked on my test server because the test server incorrectly had more than one host header defined, which seems to translate into more than one base address defined in WCF, which is a no-no. i originally used the on the test server because i was getting an error about more than one base address for http, and without realizing the real problem, I filtered out the one I wanted using . Thsi won't work locally because I have no host headers defined, so the filter provided nothing and the relative addressing attempt failed because no base address was specified.

I'm going to do some more experimenting to see what the best set-up for my situation is, but checking the host headers in IIS definitely helped. Also, this link was a huge help in understanding what was really going on.

JHubSharp