Tips for Launching WCF Test Client

Zaiyue Xue, Microsoft STB China

WCF Test Client is a debugging tool to test WCF service. It is very useful to help developing WCF service. In this blog, I will share some tips on how to launch WCF Test Client in Visual Studio.

There are 2 ways to start WCF Test Client out of Visual Studio. The first way is double click WcfTestClient.exe in the folder “Visual Studio installation path\Common7\IDE”. The other way is type the “WcfTestClient” command in “Visual Studio Command Prompt” as shown in Diagram 1:

CMD_EN

Diagram 1

In Visual Studio, different project templates provide different ways to launch WCF Test Client. The following form is all the WCF related project templates in Visual Studio 2010 Beta2:

Template Name

Template Path

.NET Framework Version

WCF Service Library

New Project -> WCF Node

3.0/3.5/4.0

WCF Service Application

New Project -> Web Node

3.0/3.5/4.0

WCF Workflow Service Application

New Project -> WCF Node

4.0

Sequential Workflow Service Library

New Project -> WCF Node

3.5

State Machine Workflow Service Library

New Project -> WCF Node

3.5

Syndication Service Library

New Project -> WCF Node

3.5/4.0

WCF Service

New Web Site

3.0/3.5/4.0

Form 1

WCF Service Library, Sequential Workflow Service Library and State Machine Workflow Service Library:

When starting debugging (F5), it will host the service in the WCF Service Host by default. And the WCF Test Client will automatically start for you to test the service. Please see the Diagram 2:

WCF Service Library_EN

Diagram 2

If you don’t want to start WCF Test Client when pressing F5, you can edit “Project Properties -> Debug -> Command line arguments” as shown in Diagram 3:

NoWCFTestClient_EN

Diagram 3

WCF Service Application and WCF Workflow Service Application:

If you set the focus on the .svc or .xamlx file in Solution Explorer, WCF Test Client will start when pressing F5. Please see the diagram 4:

WAP_EN

Diagram 4

If you don’t want to use WCF Test Client when pressing F5, you can add the setting of EnableWcfTestClientForSVC property in .csproj.user file to disable WCF Test Client:

<Project>

  <ProjectExtensions>

    <VisualStudio>

      <FlavorProperties>

        <WebProjectProperties>

          <EnableWcfTestClientForSVC>False</EnableWcfTestClientForSVC>

        </WebProjectProperties>

      </FlavorProperties>

    </VisualStudio>

  </ProjectExtensions>

</Project>

By the way, .csproj file has the default value setting for EnableWcfTestClientForSVC property. If .csproj.user doesn’t set the EnableWcfTestClientForSVC property, it will use the default value in .csproj file:

<Project>

  <ProjectExtensions>

    <VisualStudio>

      <FlavorProperties>

        <WebProjectProperties>

          <EnableWcfTestClientForSVCDefaultValue>False</EnableWcfTestClientForSVCDefaultValue>

        </WebProjectProperties>

      </FlavorProperties>

    </VisualStudio>

  </ProjectExtensions>

</Project>

The following form shows the detail logic for which client is launching by setting the specific property of .csproj.user and .csproj files:

.csproj.user file setting

True

False

Not Set

Not Set

Not Set

.csproj file setting

True/False/Not Set

True/False/Not Set

True

False

Not Set

client launching

WCF Test Client

IE

WCF Test Client

IE

IE

Form 2

For example, in a project group who are using the source control, the .csproj.user file won’t be checked in, while the .csproj file will be checked in. If you only want to change the launching behavior for yourself, you should change the .csproj.user file. If you want to change the launching behavior for the whole group, you should change the .csproj file.

Syndication Service Library:

WCF Test client doesn’t support to test the kind of service, so the WCF Test client won’t start in this project.

WCF Service (Web Site) :

WCF Test Client won’t be launched automatically when pressing F5. If you want to get the same launching behavior as WCF Service Application, you can change the websites.xml file as following (at “C:\Users\<username>\AppData\Local\Microsoft\WebsiteCache” folder. XP/2003 is in a similar location):

<DesignTimeData>

                <Website RootUrl="C:\" CacheFolder="WCFService1" EnableWcfTestClientForSVC="true" />

</DesignTimeData>

You need to close your solution, and then make the above change. It only loads the property up when project load time and will overwrite when the project closed.

Comments

  • Anonymous
    January 03, 2010
    Thank offer this program.

  • Anonymous
    March 31, 2011
    Excellent article! But.... why is this NOT an VStudio or Project-option?!?  How ridiculous to hafta make this change when I want to switch test-clients, for whatever reason.  I'm hopeful this will be addressed in future updates.  For now, it seems like an option that was added at the last minute...

  • Anonymous
    August 13, 2011
    Here is a great article for working through WCF issues for an enterprise: msdn.microsoft.com/.../hh273114.aspx

  • Anonymous
    August 13, 2011
    Here is a great article for the decisions you need to make when developing a WCF project: msdn.microsoft.com/.../hh273114.aspx

  • Anonymous
    August 24, 2011
    I'm not sure what the WCF Test Client's purpose is.  It doesn't seem to do anything.

  • Anonymous
    September 22, 2011
    How does one use this tool for a 64-bit compiled service?  Take a stock WCF Service application, set the target platform to 64-bit and try to use the WCF Test Client.  It doesn't work.

  • Anonymous
    October 16, 2011
    I'm using the WCF Test Client when debugging my WF4 workflow service... it works great for initial testing.  However, I periodically get the following error message when I hit F5 and I can't figure out how to resolve it: "Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata." Can anyone tell me how I can resolve this issue?

  • Anonymous
    May 08, 2012
    Nice article! Here's another way to automate test WCF services: jordi-montana.blogspot.com.es/.../testing-wcf-restful-services-with-post.html Hope you enjoy it!

  • Anonymous
    October 23, 2013
    Good Article. It helped me a lot. Here is one more interesting article - www.csharptutorial.in/.../cnet-how-to-test-wcf-web-service-in.html

  • Anonymous
    December 12, 2014
    Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata.