wcf service wsdl domain name

When creating a new WCF and hosting locally or dev/prod server you might come across an issue where WSDL will display a URL with computer/local name which is different to URL of service

Fro example actual URL might be

https://localhost/HelloWorldServiceSecure/HelloWorldService.svc

And WSDL URL will be

https://AK/HelloWorldServiceSecure/HelloWorldService.svc?wsdl

To fix this we can add following configuration in serviceBehaviors section of config

<serviceBehaviors>
<behavior>
<serviceMetadata httpsGetEnabled=”true”/>
<useRequestHeadersForMetadataAddress>
<defaultPorts>
<add scheme=”https” port=”443″/>
</defaultPorts>
</useRequestHeadersForMetadataAddress>
</behavior>
</serviceBehaviors>

Comments are closed.