Archive

Archive for May, 2009

Configuring IIS7 to provide correct hostname in WCF WSDL and Service Metadata

May 11, 2009 4 comments

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:

Bad Metadata

Bad Metadata

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:

Edit Binding in IIS UI
Edit Binding in IIS UI

 

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.

Good Metadata

Good Metadata

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.

Highly Recommended WCF learning Resources

One of the most valuable resources from my point of view is the author and lecturer Michele Leroux Bustamante.  She has written a book published by O’Reilly called Learning WCF that is really a great step by step and practical approach to understanding the details and implications of WCF. 

She will start with a high level concept and drill down through to source code to illustrate her point.  And, because it is a learning experience, the code is in context with enough to help you implement it.  I am mentioning this because a lot of the books I have read on WCF are basically concepts mapped to islands of code, but nothing at a practical level to help me to tie them together.

One note about the book.  There is a new chapter out that covers Visual Studio 2008 and .NET 3.5, but unfortunately, there is a chance when you order online, you are not always garuanteed to get the second release.  I bought the first release last year and wanted the second release and ordered from Amazon and they still sent me the first release.  However, Michele says that really the only difference is chapter one and she did a deal with her publisher to provide that chapter in PDF form on her blog.  The link is: http://www.thatindigogirl.com/downloads/LearningWCFChapter01VS2008.pdf.

Additionally she has done a 15 part lecture series on WCF published through Microsoft’s Webcast series.   These lectures are downloadable and really very well worth the time.  The link for the WCF Webcast series is: http://agarwalmk.spaces.live.com/blog/cns!780CD8FB86EF8F7C!14966.entry?wa=wsignin1.0&sa=16708577.

I am revising this post to include several other books I found really helpful along the way:

  1. Programming WCF by Juval Lowy – publisher O’Reilly
  2. Pro WCF by Chris Peiris and Dennis Mulder – publisher APress
  3. Essential Windows Communication Foundation for .NET 3.5 by Steve Maine – publisher Addison Wesley

Maine’s Essential Windows Communication Foundation was the hardest book for me to understand at the beginning because he does not take a cookbook but a conceptual approach.  However the more I learned, the more I began gravitating to his book.  I really like it, however I have gotten a lot out of all of the books.

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.

Follow

Get every new post delivered to your Inbox.