Jan
11
2012

C#.Net How To: How To Test Wcf Service Using Wcf Test Client in VS 2010

How to test wcf service using wcf test client is one of the most searched topic on the internet by wcf beginners. Before we proceed how to test wcfservice using WcfTestClient, we should know what is wcf test client?.

What is wcf test client?

Windows Communication Foundation Test Client (WcfTestClient) is a Graphical User Interface (GUI) tool provided by Microsoft. As name suggests, this tool acts as a client for wcf service and is use to test the wcf service. This tools can be used as debugging tool for wcf service.

Before we start how to test wcf service using wcf test client, i am assuming that your WCF web service is already built and ready to test. Please refer my previous post on how to Create a WCF Web Service in Visual Studio 2010

Before proceeding with wcftestclient utility, you must know the URL of your WCF web service. Execute the web service you already created and then you will get your WCF web service URL from following screen –

WCF Service - URL
WCF Service – URL

How to test wcf service using wcf test client utility

  1. Start a visual studio command prompt. In windows 7 OS, to start Visual Studio command prompt goto Start -> All Programs -> Microsoft Visual Studio 2010 -> Visual Studio Tools -> Visual Studio Command Prompt (2010).
    You will get following command prompt.
    WCFTestClient - Visual Studio Command Prompt
    WCFTestClient – Visual Studio Command Prompt
  2. Type wcftestclient as shown below and hit enter/return key.
    Visual Studio Command Prompt - WCFTestClient
    Visual Studio Command Prompt – WCFTestClient
  3. A WcfTestClient user interface will open in another window.
    WCFTestClient - User Interface
    WCFTestClient – User Interface
  4. Goto File -> Add Service.. menu.
    WCFTestClient - My Service Projects
    WCFTestClient – My Service Projects
  5. Type your WCF web service URL in the Add Service dialog box and click OK button.
    WCFTestClient - Enter WCF service URL
    WCFTestClient – Enter WCF service URL
  6. After some processing you will get following WCF Test Client user interface.
    All your web methods will appear on the left pane under My Service Projects.
    WCFTestClient - WCF Service Properties
    WCFTestClient – WCF Service Properties
  7. Double click on any of the web method. In our case, double clicking on “WelComeMessage” web method will display request and response interface on right pane.
    WCFTestClient - WCF Service Request
    WCFTestClient – WCF Service Request
  8. Double Click on value field(null) and type your name. I am giving here value as “Brad Pitt” for name variable.
    how to test wcf service using wcf test client
    WCFTestClient – WCF Service Response

    Now click on “Invoke” button. And check the response, it will show you the response from your web method.

  9. Similarly double click on other web methods on the left pane. The corresponding request and response interface will open in right pane.

In this article we learn how to test wcf service using wcf test client. I hope you enjoyed the article. If you find this article helpful, then could you please share the article on your social media?

Following WCF articles might be of your interest…

About the Author: Ashish Ramteke

Ashish Ramteke is a Software Professional, Part time blogger and founder of C# Tutorials, a popular blog on C#.Net. Ashish is having 6 years of work experience and an engineering degree in Computer Science and Engg.

5 Comments+ Add Comment

  • thank you very much, good article

  • Very helpful..thank U

  • very good keep going

  • thanks

  • Very good! BB

Leave a comment