How to test a WCF service with Visual Studio Command Prompt?

It can be a pain sometime to test your web service and a longer process than wanted. I then found a method from the glorious web of how to use Visual Studio to test and thought I would share this with you.

To test we are going to use the WCF Test Client from Visual Studio 2010. You can find this by either going to the programs folder, which is located at ‘Start > All Programs > Microsoft Visual Studio 2010 > Visual Studio Tools > Visual Studio Command Prompt (2010)‘. The other way would to be search for ‘visual studio command prompt’ in the start menu like below.

w1

 1) Once it is loaded you should get the command prompt showing like below:

w2

2) Type in the following command ‘wcftestclient‘ and click enter.

w3

3) You should then be presented with the WCF Test Client window like this:

w4

4) To add a new service, click the ‘File’ button from the menu, then ‘Add Service…’

w5

5) You will now be prompted with another window to enter the endpoint of your service. This can be a full domain or even a local one as long as it has a WSDL.

w6

6) Once your service is added, you will see the public methods with the pink box next to them and there is also the configuration file called ‘Config File’. If you double click on the public method you will be presented with the Request and Response sections.

w7

The Request section shows all the parameters, that the method accepts including the Type as well. Enter in the correct values and then press ‘Invoke’ to trigger the service.

You should now have a response back in the Response section.

Advertisements

Leave a message please

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s