I have a WCF Service started by code (by creating a BasicHttpBinding, a ServiceHost, and so on). The WSDL published by this service, however, has its hostname hardcoded. I.e. I tell the service that it runs on example.com and the WSDL will have imports such as
<xsd:import schemaLocation="http://example.com:8018/MyService" etc etc>
Now, from example.com itself I may wish to refer to this service by http://localhost:8018/MyService instead of example.com. However, the xsd imports will still refer to the preconfigured address.
Isn’t there a way to make the service use whichever host the WSDL page was called by inside the WSDL? Or just use a relative address? (assuming clients support that; I’m not actually sure)
The reason why this matters is that the service is addressed by servers in the same server park through its internal IP address, but by external services through its external hostname. We’d like to avoid all traffic going out of and into the subnet again simply because we can’t get WCF to understand that it may have different hostnames. Our current solution is the modify the hosts file in internal clients to make the external hostname point to the internal IP, but this is messy and error prone when e.g. changing server settings or upgrading.
This should be solved by using useRequestHeadersForMetadataAddress service behavior.