Thursday, November 15, 2012

WCF REST service on Windows 2008 R2

I developed a WCF REST service on my Windows 7 machine where worked fine. I happened to port my WCF REST application onto a branch new Windows 2008 R2 machine. So to migrate the WCF app to new Windows 2008 R2, I installed IIS Server and published a WCF REST service files as a Web Application on Default Web Site. Since this is REST service, I can use my web browser to invoke the web service. So I tried that, but of course, I was not able to invoke REST service... My test trial like http://localhost/wcf/service1.svc/test in a web browser gave me "HTTP Error 404.0 - Not Found" error.
So after wasting a few hours, I learned that I am missing two components in Windows 2008 R2.
  • Installing IIS server does not automatically install ASP.NET. Actually this does not only apply to Windows 2008. Other OSs like Windows 7 also requires to install ASP.NET after installing IIS.
    • How to setup ASP.NET
                    Run C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis.exe -i 

                    Run C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis.exe -i
  • Add Application Server role in Windows 2008 R2. This requires only in Windows 2008 and above.
    • How to add Application Server
      • Open [Server Manager]
      • RightClick [Roles] and click [Add Roles]
      • Choose [Application Server] in the Wizard.
 After setting up both requirements, I was able to access REST service from web browser :-)

1 comment:

  1. In Windows 2012, instead of aspnet_regiis.exe, need to add ASP.NET 4.5 feature from Server Manager - Add Features. In 2nd step, add the same Appication Server with Web Server selected in the wizard.