views:

104

answers:

1

I have defined two endpoints in my App.Config file as

 <system.serviceModel>
    <services>
      <service 
              name="HostDirectAddress.ITestService" 
              behaviorConfiguration="behaviorConfig">

      <endpoint 
                address="net.tcp://localhost:9000/ITestService"
                binding="netTcpBinding"
                contract="HostDirectAddress.ITestServiceContract"/>

    <endpoint
                address="http://localhost:9000/mex"
                binding="mexHttpBinding"
                contract="IMetadataExchange" />

    </service>
   </services>
        <behaviors>
           <serviceBehaviors>
            <behavior name="behaviorConfig">
              <serviceMetadata httpGetEnabled="true"/>
              <serviceDebug includeExceptionDetailInFaults="True"/>
            </behavior>
          </serviceBehaviors>
 </behaviors>
</system.serviceModel>

My client calls

static void Main(string[] args)
{
      ServiceHost host = 
        new ServiceHost(typeof(HostDirectAddress.ITestService));
      host.Open();
      Console.WriteLine("....Service is Ready to Consume...");
      Console.ReadLine();
 }

I received the following error when i try to launch the host

The HttpGetEnabled property of ServiceMetadataBehavior is set to true and the HttpGetUrl property is a relative address, but there is no http base address. Either supply an http base address or set HttpGetUrl to an absolute address.

How to fix it?

+2  A: 

The error message tells you how to fix it!

1) Add a base address

<service 
    name="HostDirectAddress.ITestService" 
    behaviorConfiguration="behaviorConfig">
    <host>
       <baseAddresses>
          <add baseAddress="http://localhost:9000/" />
       </baseAddresses>
    </host>
    <endpoint
            address="mex"
            binding="mexHttpBinding"
            contract="IMetadataExchange" />

OR:

2) Define a fixed and complete HTTP address in your service behavior:

<behavior name="behaviorConfig">
    <serviceMetadata 
        httpGetEnabled="true"
        httpGetUrl="http://localhost:9000/mex" />
    <serviceDebug includeExceptionDetailInFaults="True"/>
</behavior>

Do one or the other - and things should work just fine.

marc_s
oh! Thanks now it is working fine sir.