24 December 2010

WCF Not Using My Domain Name, But Rather My Computer Name When Viewing MyService.Svc?Wsdl

HOWTO: Fix WCF Host Name on IIS
By gavinmckay
This is a problem I have tripped across before, and it just popped up again. Time for a post on how to fix it, mainly so I won’t have to track down MSDN articles and obscure posts to remember how to do it!

When building a WCF Web Service on your local machine, the service will automatically generate WSDL for you with an address similar to http://YOURPC/MyService.svc. This works fine when testing locally, but when you want to publish this to your production environment so it can be used by World + Dog, it doesn’t respect the fact you have a nice URL you would like to use instead. For example, if your production server is “Server01″ and the URL you have assigned to the website in IIS is my.publicserver.com, your service may look like this:


Instead of displaying the “real” URL (my.publicserver.com), it displays the name of the server (server01) instead. Not at all what is required! Worse still, connections to your web server will fail because the WSDL is pointing to the non-published server name and your client won’t be able to get there. This is because WCF automatically uses the IIS Site Bindings to determine what the base addresses for the service should be.

The solution is to update the IIS metabase so IIS knows what to do with the request, then WCF will pick up on this. To fix this, perform the following steps.

Get the Website Identifier from IIS

To change the site bindings you need to know which site to change. Open the IIS Manager to view the sites available, find the one you want to change, and record the website id in the “Identifier” column. You will need this in the next step.
.....


Copied from gavin mckey blog

No comments: