What’s new in WCF Web API Preview 5 – introducing the test client

Written on September 19, 2011

This posting is the first posting in a series of blog posts to show you what has changed from WCF Web API Preview 4 to Preview 5.

If you've already been working with WCF Web API in Preview 4, you may have extensively used Fiddler to create your requests or inspect your responses.

If you're working on your own machine, you may have Fiddler installed. But if you're e.g. at your customers site this may not be the case.

This is where the WCF Web API test client which has been introduced with Preview 5 comes pretty handy.

To enable the test client, you have to set the EnableTestClient-Property of the WebApiConfiguration to true:

public class MvcApplication : System.Web.HttpApplication {

    protected void Application_Start() {
        var config = new WebApiConfiguration();
        config.EnableTestClient = true;
        RouteTable.Routes.MapServiceRoute("contacts", config);

To start the test client for our contacts list which is available at http://localhost:9208/contacts we simply add the /test fragment to the uri: http://localhost:9208/contacts/test:

WCF Web API test client

As you can see, the test client lists the Resources available under the specified uri.

When clicking on the uri, the Request form gets filled:

GET with the WCF Web API test client

When invoking the Api by clicking the "Send" button, we get our list of contacts:

XML Response in the WCF Web API test client

The test client also allows you to set the Accept-Header, e.g. application/json with sort of IntelliSense:

IntelliSense in WCF Web API test client

The result is corresponding:

application/json in the WCF Web API test client

If your Api allows other HTTP methods then the test client allows you to select them from the drop down (not supported methods are disabled):


As POST is enabled, we'll POST a new Contact:

POSTing application/json with the WCF Web API test client

In this sense: Happy testing Winking smile

DotNetKicks-DE Image