Question

We have written a restful service using WCF and are now trying to write FitNesse tests to verify the behaviour of this service.

One test is that a 404 status code is returned if a resource can not be found.

The problem is that we can not find a mechanism for consuming the service that allows us to get the status code of the incomming response. Everything seems to work fine for everything other than 200. We have tried using HttpWebRequest and HttpWebResponse and the WebChannelFactory all of which throw exceptions of various types depending on the HttpStatusCode returned by the service.

Why can't I see the status code???!!

Was it helpful?

Solution

You can see the status code, in properties of the WebException that is thrown. You can get ex.Status. Then, you can get ex.Response, and access the status code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top