Tuesday, September 09, 2014

Windows 8, IIS WCF Service Fails to Add Service Reference

Symptom,


When I tried to add a WCF Service Reference to a WCF Application hosted on IIS 8 (Windows 8), I got the following type of message,

'http://localhost/MyDataServices/DataService.svc/_vti_bin/ListData.svc/$metadata'.
The request failed with HTTP status 404: Not Found.
Metadata contains a reference that cannot be resolved: 'http://localhost/DataServices/DataService.svc'.
The remote server returned an unexpected response: (405) Method Not Allowed.
The remote server returned an error: (405) Method Not Allowed.
If the service is defined in the current solution, try building the solution and adding the service reference again.

Root Cause


The IIS configuration is incorrect or has become corrupted in some ways.

How I Got It To Work Right

  1. Uninstall and Reinstall IIS from Programs and Features
  2. When re-installed the IIS, be sure to restart the computer. The OS will not ask you to restart on re-install, but in my case the IIS was completely stuck.
  3. Next and most important is this, Be sure that in the .NET Framework 4.5 Advanced Services, and under WCF Services, the HTTP Activation is enabled. 


Side Notes/ Don't Go There...

  • First test with the IIS Express built into your Visual Studio. If that does not work, then there can be a coding issue.
  • Do not bother with editing the web.config file yet (to create behaviors and endpoints). The default ought to work.