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|
How to test wcf service using wcf test client utility
- 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
- Type wcftestclient as shown below and hit enter/return key.
Visual Studio Command Prompt – WCFTestClient
- A WcfTestClient user interface will open in another window.
WCFTestClient – User Interface
- Goto File -> Add Service.. menu.
WCFTestClient – My Service Projects
- Type your WCF web service URL in the Add Service dialog box and click OK button.
WCFTestClient – Enter WCF service URL
- 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
- 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
- Double Click on value field(null) and type your name. I am giving here value as “Brad Pitt” for name variable.
WCFTestClient – WCF Service Response
Now click on “Invoke” button. And check the response, it will show you the response from your web method.
- 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…
- How to Create WCF service.
- How to consume WCF service.
- How to host wcf service in IIS.
- How to consume wcf service in Asp.net Application.
- More WCF articles…