ContextExchangeMechanism 列舉


指定要使用 HTTP cookie 還是 SOAP 標頭,做為用戶端與服務間交談的內容交換機制。Specifies whether an HTTP cookie or a SOAP header is the mechanism used to exchange context for a conversation between a client and service.

public enum class ContextExchangeMechanism
public enum ContextExchangeMechanism
type ContextExchangeMechanism = 
Public Enum ContextExchangeMechanism


ContextSoapHeader 0

SOAP 標頭是用來交換內容的。A SOAP header is used to exchange context. 這是預設的交換機制。This is the default exchange mechanism.

HttpCookie 1

HTTP cookie 是用來交換內容的。An HTTP cookie is used to exchange context.


使用 ContextExchangeMechanism 屬性或 ContextBindingElement(ProtectionLevel, ContextExchangeMechanism) 建構函式,指定用戶端與服務間交談的 ContextExchangeMechanism 值。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. 代表用戶端需求、以支援 SOAP 層級的內容交換通訊協定或要求啟用 HTTP cookie 支援的原則判斷提示,可由端點發行。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. ContextExchangeMechanism 屬性值會決定是否在服務原則中產生這些判斷提示,如下所示:The generation of these assertions into the policy on the service is controlled by the value of the ContextExchangeMechanism property as follows:

  • 若為 HttpCookie, 則會產生下列判斷提示:For HttpCookie, the following assertion is generated:

    <HttpUseCookie xmlns=""/>  
  • 若為 CoNtextSoapHeader, 則會產生下列判斷提示:For ContextSoapHeader, the following assertion is generated:

    protectionLevel="Sign" />  

HttpCookie 列舉會在傳輸層中執行。The HttpCookie enumeration is implemented at the transport layer. Simplex 通訊可使用它,此時,用戶端建立一個初始要求,而內容則由服務在對應的回覆中提供。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. 針對使用 HTTP 傳輸的服務端點, 以及同意允許使用 HTTP cookie 的用戶端, 可以使用 HttpCookie 列舉來交換應用程式內容。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. 一旦使用 HTTP Cookie 來傳播內容,就應該透過傳輸安全性來保護這些 Cookie 的安全。When HTTP cookies are used to propagate context, they should be protected using transport security. 這個機制無法與非 HTTP 傳輸一起使用。This mechanism cannot be used with non-HTTP transports.

CoNtextSoapHeader 列舉提供的替代方法是在自訂內容通道中執行, 並可與非 HTTP 傳輸和其他訊息交換模式 (例如要求-回復和雙工會話) 搭配使用。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. 此內容交換通訊協定提供由傳輸層 HTTP cookie 所提供、與 SOAP 相等的功能。This context exchange protocol provides a SOAP-based equivalent of the feature offered by HTTP cookies at the transport layer. 它引進新的 wsc:Context SOAP 標頭來代表內容資訊。It introduces a new wsc:Context SOAP header to represent the context information. 轉換時,必須保護 wsc:Context 標頭,避免遭到篡改,其理由與 WS-Addressing 標頭需要保護的理由相同︰訊息到達時,這些標頭是用來將訊息分派給正確的工作流程執行個體。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. 因此,當繫結提供訊息保護功能時,wsc:Context 標頭必須在 SOAP 或傳輸層經過數位簽署。The wsc:Context header is therefore required to be digitally signed at either SOAP or transport level when the binding offers message protection capability.

通道層級會透過 ContextMessageProperty,在應用程式層級中來回傳送內容。The channel layer communicates the context to and from the application layer using ContextMessageProperty.