October
17th,
2006
One extensibility hook in Windows Communication Foundation I've been playing with recently is the IDispatchMessageInspector interface, which allows you to see the messages arriving at an endpoint before they have been dispatched as well as the corresponding response message before it is sent back to the client.
A couple of points I noticed about the BeforeSendReply() method that might be useful:
- If the operation the message was dispatched to was a One-Way operation, this method will still be invoked by the WCF runtime on your IDispatchMessageInspector implementation when the operation has finished its execution. However, the "reply" argument representing the response message will be null, so be sure to check for that before manipulating the message.
- You can detect in your implementation if the operation the message was dispatched to threw an exception/fault, by checking the IsFault property of the reply message. This will be even true for one-way operations (even though the client will never see it, the server side dispatcher still correctly notifies the message inspectors about it).
Technorati: Windows Communication Foundation, WCF, IDispatchMessageInspector