0

I have created a web service application (hosted in IIS) using WCF. When I attempt to create a service reference on the client side, the address generated is the server name on the local network (e.g. server1.corporate.darkbond.com). I'd like the client WSDL to reference the actual published name (e.g. manager.darkbond.com). Is there any way to accomplish this on the server side using WSDL rather than editing the client configuration file after each update?

Quark Soup
  • 4,272
  • 3
  • 42
  • 74
  • The address is, I believe, generated based on the address of the service providing the WSDL. You should be able to change the address of the service on the client side. – Tim Apr 01 '16 at 19:15
  • See the answer for this [question](http://stackoverflow.com/questions/5007270/how-to-change-wsdl-url-from-internal-machine-name-to-public). If you apply the suggested solution the service location in the WSDL document will match what the client used to access the WSDL. – Amith Sewnarain Apr 01 '16 at 20:02
  • The example demonstrates how to change the port designations. I could find no example of the URL being changed. What am I missing? – Quark Soup Apr 01 '16 at 20:51
  • @DRAirey1 I added a more direct answer – Amith Sewnarain Apr 05 '16 at 05:56

1 Answers1

1

If you would like the address in the generated WSDL to match the address the client used to access the WSDL, for example via a load balancer host name, use a serviceBehavior with the useRequestHeadersForMetadataAddress added.

<serviceBehaviors>
    <behavior name="myBehaviour">
      <useRequestHeadersForMetadataAddress />
      <serviceMetadata httpGetEnabled="true"/>
    </behavior>
</serviceBehaviors>
Amith Sewnarain
  • 655
  • 6
  • 11