Expand Minimize
This topic has not yet been rated - Rate this topic

ContextExchangeMechanism Enumeration

Specifies whether an HTTP cookie or a SOAP header is the mechanism used to exchange context for a conversation between a client and service.

Namespace:  System.ServiceModel.Channels
Assembly:  System.ServiceModel (in System.ServiceModel.dll)
public enum ContextExchangeMechanism
Member nameDescription
ContextSoapHeaderA SOAP header is used to exchange context. This is the default exchange mechanism.
HttpCookieAn HTTP cookie is used to exchange context.

Use the ContextExchangeMechanism property or the ContextBindingElement(ProtectionLevel, ContextExchangeMechanism) constructor to specify the value of the ContextExchangeMechanism for a conversation between a client and service.

Service endpoints that require support for the context exchange protocol can make this requirement explicit in their published policy. Policy assertions that represent the requirement for the client to support the context exchange protocol at the SOAP level or that require the enabling of HTTP cookie support can be published by an endpoint. The generation of these assertions into the policy on the service is controlled by the value of the ContextExchangeMechanism property as follows:

  • For HttpCookie, the following assertion is generated:

    <HttpUseCookie xmlns=”http://schemas.xmlsoap.org/soap/http”/>
    
  • For ContextSoapHeader, the following assertion is generated:

    <IncludeContext 
    xmlns=”http://schemas.microsoft.com/ws/2006/05/context”
    protectionLevel=”Sign” />
    

The HttpCookie enumeration is implemented at the transport layer. This can be used in the case of simplex communication, where the client makes an initial request and the context is provided by the service on the corresponding reply. All subsequent messages between the service and client for the lifetime of that conversation contain the context. For service endpoints that use an HTTP transport and clients that agree to allow the use of HTTP cookies, the HttpCookie enumeration can be utilized to exchange the application context. When HTTP cookies are used to propagate context, they should be protected using transport security. This mechanism cannot be used with non-HTTP transports.

The ContextSoapHeader enumeration provides an alternative that is implemented in a custom context channel and that can be used with non-HTTP transports and other message exchange pattern, such as request-reply, and a duplex session. This context exchange protocol provides a SOAP-based equivalent of the feature offered by HTTP cookies at the transport layer. It introduces a new wsc:Context SOAP header to represent the context information. The wsc:Context header must be protected from modification while in transit for the same reason as the WS-Addressing headers must be protected: upon arrival, these headers are used to dispatch the message to the correct workflow instances. The wsc:Context header is therefore required to be digitally signed at either SOAP or transport level when the binding offers message protection capability.

The channel layer communicates the context to and from the application layer using ContextMessageProperty.

.NET Framework

Supported in: 4, 3.5

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.