Configuring IIS7 to provide correct hostname in WCF WSDL and Service Metadata
I ran into a problem when I started to host WCF services on Server 2008 in that I kept getting the netbios name of the server instead of the service website in the service metadata and WSDL.
I created a website with a unique IP address on my Windows 2008 server with the address of http://IISHostedServices.maltercorp.com and the virtual website to host the service is MaltercorpService. When I browsed on my service, I got the following metadata page:
As you can see in the address bar, the correct ip address is used, but the complete URL of the website does not appear. A little further down you can see that the metadata page thinks I am pointing to mmant2 which is the netbios name of the server. It’s address is 10.1.2.0.
The fix was to edit the binding of the website and to use the same name I used in DNS to point to the site. I want to point out that there are a number of blog entries out there that explain how to fix this problem but they are recommending the use of the IIS utility tool adsutil.vbs, killing the w3wp.exe process and several other steps.
I am adding my solution because it differs in that the IIS UI was used to change the binding. Personally I found it easier to use the UI as shown in the screenshot below. I did not have to do anything additional after adding a hostname:
After adding the hostname, which is the same address I configured DNS to point to, I simply restarted the site and when I browsed on the service, this time the correct name of the website appeared on the metadata page. Also notice that in the address bar, instead of the ip address appearing, the actual URL for the web site appears.
Just as an FYI, in a related post, I am writing a series of articles on a practical WCF architecture. The first post is here.
- Daniel DieuHoa Ho on Security Exception when using AJAX Control Toolkit on Server 2008
- Mike Malter on Break out of WebForm_DoPostBackWithOptions Hell
- I. Hsu on Break out of WebForm_DoPostBackWithOptions Hell
- Mike Malter on Cloning Virtual Machines using Hyper-V Without the Pain
- lazydj on Cloning Virtual Machines using Hyper-V Without the Pain
- 58,225 hits