WCF Service Endpoints vs Host Base address

Ryan Burnham picture Ryan Burnham · Aug 4, 2011 · Viewed 72k times · Source

so i'm a litle confused over what the service endpoints and host base address is for. In all the examples i have walked through so far they talk about setting up the endpoints with the required bindings and you can normally navigate to those endpoints

Hoever when i use the following config to set up and host my service it only seems to expose the Hosts base address.

    <configuration>
      <system.web>
        <compilation debug="true" />
      </system.web>
      <!-- When deploying the service library project, the content of the config file must be added to the host's
      app.config file. System.Configuration does not support config files for libraries. -->
      <system.serviceModel>
        <services>
          <service name="HostService.EvalService">
            <endpoint address="http://localhost:8080/basic"
              binding="basicHttpBinding" contract="HostService.IEvalService" />
            <endpoint address="http://localhost:8080/ws"
              binding="wsHttpBinding" contract="HostService.IEvalService" />
            <endpoint address="mex" binding="mexHttpBinding"
              name="mex" contract="IMetadataExchange" />
            <host>
              <baseAddresses>
                <add baseAddress="http://localhost:8080/EvalsService" />
              </baseAddresses>
            </host>
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="">
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
    </configuration>

Can someone explain this to me?

Answer

Kiran Mothe picture Kiran Mothe · Aug 4, 2011

When you host the WCF service on IIS, the base address can only be the URL to the .svc file. If you specify any other base address, it's ignored. You can still specify the relative URI for your endpoints, such as address="basic" or address = "ws". Then the address on the endpoint becomes <URL to the .svc file>/basic and <URL to the .svc file>/ws in this case.