Wcftestclient can be used to debug a WCF service. Here are two ways to enable wcftestclient debugging in Visual Studio VS2008 SP1 web applications.
Tradition way:
In Web application project property page, web tab, one can specify start external program and command line argument for IIS based WCF:
1. Check Use Local IIS Web server and create a virtual directory on the local IIS (you’ve to enable WCF on .net3.0 with IIS7)
2. Specify start external program: C:Program FilesMicrosoft Visual Studio 9.0Common7IDEWcfTestClient.exe
3. Specify command line argument: http://localhost/WcfService7/Service1.svc
The problem with this approach is that if the project contains several wcf service or some other web page, ctrl-F5, F5 will still start the svc file.
A hidden feature in VS2008 SP1:
This is a hidden feature in VS2008 SP1, one can turn a project flag to enable wcftestclient.exe when debugging or run the svc file.
For Web Application Project
1. Make sure the Start action is “current page” instead of the “start external program”. Servers can be either “Use Visual Studio Development Server” or “Use Local IIS Web server”.
2. Check the project directory, there is a file with .user extension, such as wcfservice7.csproj.user. Open it.
3. This file is a xml file, near the end, there is a setting of:
<EnableWcfTestClientForSVC>False</EnableWcfTestClientForSVC>
4. Change the value to True
5. Restart VS and reopen the project
6. Focus to a svc file or its code behind file.
7. Press Ctrl-F5 or F5
The wcftestclient.exe will be automatically started for the current svc page.
For website with wcf service
This is a bit harder as the website does not have a project file. Do the following:
1. Close the Visual studio, so websites.xml file get updated
2. go to C:Users<username>AppDataLocalMicrosoftWebsiteCache (This is Vista/Win2k8, XP/2003 is in a similar location)
3. Open websites.xml using an editor:
4. Find the line for the newly created website
<Website RootUrl="D:SharesProgramsTestWCFService3" CacheFolder="WCFService3" addnewitemlang="Visual Basic" targetframework="3.5" vwdport="6442" _LastAccess="4/9/2009 3:57:04 PM"/>
5. Add a new attribute enablewcftestclientforsvc =”True”, so it looks like following:
<Website RootUrl="D:SharesProgramsTestWCFService3" CacheFolder="WCFService3" addnewitemlang="Visual Basic" targetframework="3.5" enablewcftestclientforsvc=”True” vwdport="6442" _LastAccess="4/9/2009 3:57:04 PM"/>
6. Save the xml file
7. Start VS, and reload the project
8. Focus to svc file or its code behind file
8. Press Ctrl-F5 or F5
The wcftestclient.exe will be automatically started for the current svc page.
Please note, this is only a workaround to help customers to launch wcftestclient for svc files more easily. We didn’t make it true by default due to the limitation of the design. Hopefully, we can provide a better solution in the future.
Xinyang Qiu
SDETII
Visual Studio Web Tools
0 comments