I needed to deploy a WCF Web service to a Windows 2003 server today. I was happy to realize that .NET 3.5 and .NET 3.5 SP1 were both installed, so I thought I was home free. Hardly. Here are the steps I needed to take to get the WCF 3.5 service running on the Windows 2003 server.
Making IIS recognize the .SVC extension
The first problem I had was that I got a 404 error when I tried to load the .SVC file in a browser. I knew I had the file name specified correctly and previous experience with JSON and IIS lead me to believe that IIS didn’t know about the .SVC file type. A little checking made me quickly realize that the .SVC file wasn’t mapped to the ASPNET_ISAPI.DLL in Windows 2003 Server’s IIS 6.0.
Before I did that manually, I read this MSDN article and learned about the ServiceModelReg.exe. This exe registers script maps in IIS. I ran it on the server and it finished very quickly. The MSDN article recommends checking the SVC ISAPI mapping after having run this program, but the mapping was now in place for me. If it’s not for you, there are instructions at the end of the article that show how to map the .SVC extension to the ASPNET_ISAPI.DLL. (For what it’s worth, I did need these mapping instructions when attempting to host the service on my Windows 7 development box.)
Preventing anonymous access to the service
I thought I was home free. Alas, another error. When I attempted to load the .SVC file with the browser again, the file was now found but the error returned was ‘Anonymous’ Authentication but it is not enabled for the IIS application that hosts this service." Hmm. I knew that I had anonymous access configured for the virtual directory—something seemed very screwy. A little googling lead me to this article on Nicholas Allen’s Indigo Blog. He clearly explained exactly the scenario I was experiencing.
To fix the problem, I disabled anonymous access on the virtual directory and then added the following <security> node to Web service’s binding configuration.
1<basicHttpBinding>
2 <binding name="allowBigData" maxReceivedMessageSize="2000000">
3 <readerQuotas maxArrayLength="2000000" maxBytesPerRead="2000000"/>
4 <security mode="TransportCredentialOnly">
5 <transport clientCredentialType="Windows" />
6 </security>
7 </binding>
8</basicHttpBinding>
Be sure to read Nicholas’s article closely—gotchas lurk if you’re using WSHttpBinding.
Thanks to Nicholas and MSDN, my service works now!
rp



