8

I have 2 WCF serivces hosted in IIS server.

Here is web.config

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="HttpBinding" />
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="BShop.Services.BubensService">
        <endpoint address="http://localhost:9001/BubensService" binding="basicHttpBinding"
          bindingConfiguration="HttpBinding" name="" contract="BShop.Services.IBubensService" />
      </service>
      <service name="BShop.Services.OrdersService">
        <endpoint address="http://localhost:9001/OrdersService" binding="basicHttpBinding"
          bindingConfiguration="HttpBinding" contract="BShop.Services.IOrdersService" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="false" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>

When I try to run it I got

No protocol binding matches the given address 'http://localhost:9001/BubensService'. Protocol bindings are configured at the Site level in IIS or WAS configuration.

What I missed in config?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
VoimiX
  • 1,180
  • 3
  • 16
  • 31

3 Answers3

24

When you host your WCF services in IIS, your address defined in the service endpoints is not the one you need to use.

<endpoint 
      // this is **NOT** the address you can use to call your service! 
      address="http://localhost:9001/BubensService"

Rather, the web server, its port (usually 80) and the virtual directory plus the SVC file determine your service address. So you service addresses here would be:

http://YourServer/YourVirtualDirectory/YourServiceFile.svc/

What you can do is define relative addresses, e.g.:

<service name="BShop.Services.BubensService">
   <endpoint name="" 
             address="BubensService" 
             binding="basicHttpBinding" bindingConfiguration="HttpBinding"  
             contract="BShop.Services.IBubensService" />
</service>

Then this service would be callable at :

http://YourServer/YourVirtualDirectory/YourServiceFile.svc/BubensService
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • what is the difference between defining the address in the endpoint and if we define a baseurl? Do 2 base url, 1 server targeting other localhost targeting solve the problem? – Emil Nov 22 '13 at 14:22
0

Just for the benefit of people searching. I came across this problem. To fix it I reviewed the web.config using marc_s 's answer then did the following as I still had problems:

  1. Delete Virtual Directory.
  2. Went to project properties - > Web Panel -> Selected 'Use Local IIS Web Server' with project url of http://{localhost}/{myservice} (obviously without the braces) and re-created the virtual directory.
  3. Changed the App Pool to .NET 4 with integrated pipeline mode. The app pool change seemed to fix it.
Community
  • 1
  • 1
JsAndDotNet
  • 16,260
  • 18
  • 100
  • 123
0

N.B. If anyone facing this problem while viewing WCF service in browser during development using Visual Studio, this one is for them.

I was facing this problem when trying to view my .svc service from VS after assigning a value to endpoint address attribute in Web.config file, but if I don't assign the endpoint address attribute a value then it works perfectly. WCF Service Config File

quasar
  • 404
  • 6
  • 17