Wednesday 29 June 2011

How to test a WCF Service easily ?

After deploying a WCF service, you may need to check his availability or test its validity. Or in developpment phase or unit testing , you need to test your service independantly.
There is a lot of tools like SOAP-UI,... to do it.
But natively, you can use the tool named wcftestclient.
To start it : start > Microsoft Visual Studio [2008/2010]/Visual Studio Tools > Visual Studio Command Prompt [2008/2010]
At the prompt command, type wcftestclient, and the Wcf test client window appears.

On the File > Add Service, you can enter the URL of your service.
After the service has been loaded, you can invoke it by entering values of input parameters  in the second columns (or none if it has any input param) and click the button invoke.
If the operation contract returns values, they are displayed in the above grid.

In this way, you can invoke your service directly as it will be invoked by your application but free you all the UI processes ( eg : fill form, and submit)