Jun 22, 2010

Domain name replaced with Machine Name in WCF Service

I personally came across this issue WCF was taking machine name not IP address or domain name and also I got questions from forums about “how to replaced Machine Name with Domain name in WCF Service wsdl link?”. This occurs when we host WCF service on IIS then the links to wsdl is uses local machine name not the domain name or IP address.


You can see in browser [here I used IP address of my machine] in wsdl link its adding my computer name, this is same issue when I publish this service on production; the wsdl link is taking name of production machine not domain.

I found some solutions which changes the bindings on server but again that is not helpful for me on production server however it works well on local machine.

Then I was checking the configurations and found solution for how Domain name replaced with Machine Name in WCF Service without playing with IIS bindings. In service behavior we can change the behavior of serviceMetadata which will FIX our problem. We need to specify on what location metadata will resides httpGetUrl or httpsGetUrl. We can add url having domain rather machine name. So final configuration should look like following which is our solution.

<service name="Demo.Service.MultiEndPointsService" behaviorConfiguration="serviceBehaviour">
<endpoint address="basic" binding="basicHttpBinding" bindingConfiguration="basicBinding" contract="Demo.Service.MultiEndPointsService" />
<behavior name="serviceBehaviour">
<serviceMetadata httpGetEnabled="true" httpGetUrl="" />
<serviceDebug includeExceptionDetailInFaults="false" />
<binding name="basicBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="None"></security>
<readerQuotas maxStringContentLength="2147483647" />

You can see value of httpGetUrl; I have specified IP address


Now let’s see again in browser.


There you goo!!!


Ashu said...

If I have already the execute the original WCF service with domain name. After that I have tried the code given but there is an error of

A registration already exists for URI -----

pehret said...

I can confirm that error message. For now, I inserted a line into the Windows hosts-file mapping the computername to the ip-address of the domain. For example if is replaced by somecomputer.somenetwork.local the entry is:

XX.XXX.XXX.XXX somecomputer.somenetwork.local

Anonymous said...


But when I click on "" it shows "The webpage cannot be found" i.e. HTTP400 Bad request.

Please let me know your feedback on this.


Anonymous said...

awesome this is a great solution thanks

Domain registration said...

Thanks for sharing this nice information. I appreciate your post. Please keep sharing more and more information. You really doing great job.

Wilver Paul said...

Thank you, thank you, thank you for sharing this.

It worked!

Wilver Paul said...

Thank you, thank you, thank you for sharing this.

It worked!

Anonymous said...

Enabling the httpsGetEnabled attribute will fix this issue.

Haridharan. R

Anonymous said...

its working for me.. Thanks!

Darko said...

Thank you very much, I searched some days to solve the problem. Now I found your website and solve it in 5 minutes perfectly.

Thank you very much once again.

Ravish Gururani said...



Thanks for sharing this

Anonymous said...

Thank you so much... you saved lot of my searching

Anonymous said...

It worked! Thank you so much! :)

Anonymous said...

It worked! Thanks a lot!!!

Sergio Venicius said...

it worked perfectly!

thanks man!