4

WCF allows you to specify an external WSDL file that should be published with the service rather than WCF's generated WSDL. In a WSDL-first design approach, it makes a lot of sense to publish the source WSDL rather than the generated WSDL.

This is set using the externalMetadataLocation:

<serviceBehaviors>
  <behavior>
    <serviceMetadata httpGetEnabled="true" externalMetadataLocation="path_to_my_wsdl.wsdl"/>
    <serviceDebug includeExceptionDetailInFaults="false"/>
  </behavior>
</serviceBehaviors>

The problem I'm encountering is that when I do this, it serves the WSDL straight-up, which has the wrong endpoint address. I want the endpoint address to be replaced at run-time with the real endpoint address of the service (which will differ depending on where it is deployed).

Is there an easy way to do this?

Chris M
  • 183
  • 2
  • 8

1 Answers1

4

I'm in no way a WCF expert but can't you do this by specifying it on the endpoint in the config file (web.config), for example:

<system.serviceModel>
    <services>
        <service>
            <endpoint 
                listenUri="https://yourdomainname.com/servicename.svc"
                address="https://yourdomainname.com/servicename.svc">

Note: "listenUri" is the physical address and the endpoint "address" is the logical address. Ie. "listenUri" is where the service really is and endpoint is what the client will be asking for.

If they are the same you don't need listenUri I believe.

Dor Cohen
  • 16,769
  • 23
  • 93
  • 161
Nick Meldrum
  • 1,141
  • 1
  • 10
  • 27