When should I use OperationContextScope inside of a WCF service?

后端 未结 1 441
春和景丽
春和景丽 2021-02-07 18:07

I\'m currently working on a WCF service that reaches out to another service to submit information in a few of its operations. The proxy for the second service is generated thro

1条回答
  •  死守一世寂寞
    2021-02-07 18:49

    If you are using callbacks or if you want to modify the message or headers then you need to use OperationContextScope. Your service might need to modify outgoing headers while calling that another service.

    When you establish OperationContextScope then you can:

    1. Access and modify incoming and outgoing message headers and other properties.
    2. Access the runtime, including dispatchers, the host, channel, and extensions.
    3. Access other types of contexts, such as security, instance, and request contexts.
    4. Access the channel associated with the OperationContext object or (if the channel implements System.ServiceModel.Channels.ISession) the associated channel's session identifier.

    The other service which you call, is it a session-based service? Probably you need to look at its sample client code or documentation if available.

    0 讨论(0)
提交回复
热议问题