user2243747
user2243747

Reputation: 2967

Role of baseAddress while configurting WCF Service EndPoint

I have created simple WCF service and configured its endpoint as bellow.

<services>
  <service name="AsynchWCFService.MathOperation">
    <endpoint address="MathsOperation" binding="wsHttpBinding" contract="AsynchWCFService.IMathOperation">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>            
        <add baseAddress="http://localhost:8080/OperationService/" />
      </baseAddresses>
    </host>
  </service>
</services>

I have hosted this WCF service in a stand alone exe. I am expecting that my service will be accessible at below address.

http://localhost:8080/OperationService/MathsOperation/

But service is accessible at http://localhost:8080/OperationService/

I want to access service using http://localhost:8080/OperationService/MathsOperation/ link. Can any one help me?

Upvotes: 0

Views: 219

Answers (1)

YK1
YK1

Reputation: 7622

I don't think your service is available at http://localhost:8080/OperationService. What you see there is just a HTML page created by WCF which describes available mex endpoints or path to WSDL. These mex endpoints describe the ABC of your WCF service where A = address => http://localhost:8080/OperationService/MathsOperation/. Potential clients know about your service url by querying the mex endpoint.

By default, this HTML page will show up at your base address. However, you can disable this page or set it to appear at some different url by using serviceDebug behavior.

<system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <behavior>
                <serviceDebug httpHelpPageUrl="http://localhost:8080/OperationService/myhelppage"
                               /> <!-- use httpHelpPageEnabled="false" to disable the page -->
            </behavior>
        </serviceBehaviors>
    </behaviors>
</system.serviceModel>

Unfortunately, I don't think you can set httpHelpPageUrl to same address as your service endpoint.

Upvotes: 2

Related Questions