For my WCF client, I'd like to be able to do some pre and post work for every operation of a given endpoint.
- The pre work would like to make use of the operation name and the input arguments.
- The post work would like to make use of (again) the operation name and the original input arguments as well as the outputs/return value or any exception that occurred.
Given this, the IParameterInspector
(with its BeforeCall
and AfterCall
) gives me almost everything I need. The problem is that
- in the case of an exception,
AfterCall
is not called (see here).
To help with that problem, I can add an IClientMessageInspector
since its AfterReceiveReply
does get called in the face of an exception. This gives me the ability to
- determine if an exception (fault) occurred or not.
- do post work in the face of an exception
Question:
- Is there a way with the
IClientMessageInspector.AfterReceiveReply
to get (or create the equivalent) exception that represents what will eventually be thrown to the callers. And if so, is there a way to mark the exception as handled such that the callers will not get the exception? - Or, is there some other extensibility mechanism or other approach I should be using to meet my goals?