views:

40

answers:

0

I have written a custom WCF binding which replies to requests over HTTP from a different source.

In the Channel's ReceiveRequest method, it's possible to receive a bad request from a client (for example, if he does not send HTTP etc..) However, due to the non-existance of a RequestContext at this time point (ReceiveRequest should return the RequestContext), I cannot properly reply with a HTTP 400 Bad Request to my client.

Obviously, I could just send back the response over my connection, but what should I return then to the ServiceModel from the ReceiveRequest method? Additionaly, I would have redundancy if I would implement this approach since reply code is already inside the ReplyContext.

What is the proper way to handle those errors correctly inside of a custom binding?