I want to create a DispatchMessageInspector for my WCF service that will run before each operation, perform some processing and then make the result of that processing available to the operation.
Creating the MessageInspector is easy. However, after I do what I need to do there, where can I place the object that I create so it can be accessed by the code in each operation? In the MessageInspector, would I just store it in the OperationConext, or is there a cleaner solution?
You’d normally store this information on the message properties, then access it via the operation context on the operation (see an example in the code below).