Mene
Mene

Reputation: 3799

WCF client behavior for HTTP Status

I need to access a RESTful server, which is not created with WCF. For that I'm using a WebHttpBinding, a ChannelFactory<MyInterface> and a WebHttpBehavior.

Most things are working like expected. However, the server offers various listings and sends a response with HTTP status of 404 which raises an exception. I'd prefere to not raise an exception as an empty list is not really an excetional condition here.

Note that I have no influence on the server, I'm just writing a client. I tried to add a custom Behavior to my factory, however the exception is raised before AfterReceiveReply

Edit

I also use OAuth and I dont want to to anything besides using WCF.

How can I influence WCFs behavior on different HTTP status?

Upvotes: 0

Views: 142

Answers (1)

Hamza_L
Hamza_L

Reputation: 654

for restful services, you can use HttpWebRequest, and when reading the response stream you can handle the WebException.

simple and it works :D

Upvotes: 1

Related Questions