Search code examples
.netwcfwcf-client

Context passing in WCF pipeline


Say, I'm on a client side where the chain looks something like (simplified):

  1. Proxy method call
  2. Parameter inspection (IParameterInspector)
  3. Serialization/message formatting
  4. Message inspection (IClientMessageInspector)
  5. Channel

Are there any means to pass my context through the chain?

The problem i'm trying to solve is that IParameterInspector.AfterCall() is not get called in case of faults and I cannot obtain correlation state object i created in IParameterInspector.BeforeCall(), can I? But if I could store it in some context i would retrieve it in, for example, IClientMessageInspector.AfterReceiveReply() and be happy.


Solution

  • OperationContext is not available within IClientMessageInspector. Ended up with ThreadStatic field in hope I won't get multi-thread issues.