I have been working on an internal legacy application at our place that is being slowly moved from ASMX to WCF services. At present the services are a mixture of the two and there is a new WCF based client making connections to both types as needed. This work has been going on for a while on Vista development boxes without any problems. However when I opened the solution on a Windows 7 box (Beta 7000 build) I found I could not access the WCF services hosted locally using Visual Studio 2008’s WebDev.Webserver.exe (Cassini) server.
After a bit of digging I stripped the problem back to this:
- In VS2008SP1 create a new ASP.NET hosted WcfService, Don’t altered any of the content from the demo/sample that is in there i.e. the GetData method etc.
- Run this from within VS2008 so it is using WebDev.Webserver.exe on some port number chosen by Visual Studio, a browser will be opened and you will be able to see the WDSL
- Connect to the service using the WCF test client (C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\WcfTestClient.exe).
- It gets back the WDSL but when you try to execute a method you get the following error. The remote server returned an unexpected response: (400) Bad Request.
I tried disabling firewall, anti virus etc. but it all had no effect. I looked with Fiddler2 and there appears to be no communication to the service (remember to look at localhost in Fiddler you have to using 127.0.0.1. (note the trailing dot) or see the FAQ for other techniques.
I then repeated the process, but create a self hosted WCF service (that uses C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\WcfSvcHost.exe) as opposed to an ASP.Net one, and this worked perfectly. Also if I published the ASP.Net WCF service to a IIS server it also worked fine. So this definitely looked like a Cassini issue.
I fed these result back to Microsoft and just heard that there is a problem with one of the security initiation messages when Cassini is involved, and they are looking into it.
So for now avoid the combination of Cassini, WCF and Windows 7 Beta, the simple workarounds on Windows 7 are
- to make your WCF services self hosted during development.
- or host in IIS on you development PC
In both cases you can chose how to host them in production, it does not have to be the same, that is the great advantage of WCF.