SupportedAddressingMode 列舉


指定服務是否支援將回應只傳送至匿名位址、只傳送至非匿名位址,或兩者都支援。Specifies whether a service supports sending responses to anonymous addresses only, to non-anonymous addresses only, or to both.

public enum class SupportedAddressingMode
public enum SupportedAddressingMode
type SupportedAddressingMode = 
Public Enum SupportedAddressingMode


Anonymous 0

伺服器只支援匿名位址,因此用戶端必須提供匿名回應位址。The server only supports anonymous addresses and clients must provide an anonymous response address.

Mixed 2

伺服器同時支援匿名和非匿名位址,因此用戶端可選擇使用其中一種或兩種。The server supports both anonymous and non-anonymous addresses and clients may choose to use either or both.

NonAnonymous 1

伺服器只支援非匿名位址,因此用戶端必須提供非匿名回應位址。The server only supports non-anonymous addresses and clients must provide a non-anonymous response address.


這個列舉會用於指定伺服器的能力,而該功能將形成伺服器加諸至其用戶端上的需求。This enumeration is used to specify the capability of a server, which, in turn, imposes a requirement on its clients.

Windows Communication Foundation (WCF) 有各種定址控制項, 可用來指定訊息的傳送位置。Windows Communication Foundation (WCF) has a variety of addressing controls for specifying where messages should be sent. 例如,用於訊息目的地的邏輯 To 位址、傳輸所使用和服務接聽所在的實體位址 ("Via") 位址,以及提供用戶端端點位址之端點的 ReplyTo 位址。For example, there is the logical To address for the message destination, the physical ("Via") address, used by the transport, at which a service listens, and the ReplyTo address of the endpoint that provides the address of the client endpoint.

在最基本的情況下,即雙方只在彼此之間交換訊息時,就不必個別指定這些位址。In the most basic case, when two parties exchange messages between themselves only, it is not necessary to specify these addresses separately. 但是因為交換可能會包含其他訊息目的地,所以您必須要能夠在需要明確提供位址時指定這些位址。But because exchanges can involve other message destinations, you must be able to specify when addresses must be explicitly provided. 即使只在雙方之間進行交換,有時仍然需要這項能力,例如在伺服器必須建立自己的 HTTP 要求的雙重 HTTP 情況下。Even between just two parties this ability is sometimes required, as with dual HTTP where the server must create its own HTTP request. 下面的關係類型是由 SupportedAddressingMode 列舉定義用來擷取這些訊息模式:The following kinds of relationships are defined by the SupportedAddressingMode enumeration to capture these messaging patterns:

  • 匿名位址是最基本的定址形式。Anonymous addresses are the most basic form of addressing. 如果有預設的回應路徑,便會使用匿名定址。Anonymous addressing is used when there is a default path for a response. TCP 是雙向通訊傳輸,而 TCP 訊息的回應可以傳回至傳送原始訊息之通訊端的另一端。TCP is a bi-directional communication transport and the response to a TCP message can be sent back to the other side of the socket that sent the original message. 同樣地,HTTP 的要求-回覆模型會透過 HTTP 回覆通道傳送回應。Similarly, the request-reply model of HTTP sends responses through the HTTP reply channel. 這些回應都不需要指定回應訊息的目的地。Neither of these responses requires specifying where the response messages are going. 當伺服器需要用戶端的匿名回應時, 它會使用列舉的匿名值。When a server requires anonymous responses from the client, it uses the Anonymous value of the enumeration. WCF 系統提供NetTcpBinding BasicHttpBinding的和WSHttpBinding系結一律會使用匿名位址。The WCF system-provided NetTcpBinding, BasicHttpBinding and WSHttpBinding bindings always use Anonymous addresses.

  • 當傳送回應時, 會使用非匿名位址, 而必須建立新的通道來進行通訊。NonAnonymous addresses are used when sending the response requires creating a new channel for communication. WCF 系統提供WSDualHttpBinding的系結會使用非匿名位址。The WCF system-provided WSDualHttpBinding binding uses a NonAnonymous address. 當使用雙重 HTTP 時,用戶端會建立 HTTP 要求以傳送訊息,接著伺服器就必須建立自己的 HTTP 要求以傳送回應。With dual HTTP, the client creates an HTTP request to send a message and then the server must create its own HTTP request to send a response. 由於伺服器將會初始化該傳送,因此它必須建立特定的端點來建立連線。Because the server is initiating the send, it must have a specific endpoint to establish the connection. 您必須為伺服器提供用於回應之端點的位址。You must provide the server the address of an endpoint for its response. 同樣地, 如果服務必須回應它所收到的單向訊息, 它也需要非匿名位址, 因為沒有可供通訊的後端通道。Similarly, if a service must respond to a one-way message that it received, it also requires a NonAnonymous address because there is no back channel available for communication. 如果伺服器傳回訊息,則需要完全不同於在傳送第一個訊息時所使用的作業。If the server sends a message back, a completely separate operation from that used to send the first message is required.

  • 混合是第三種形式的定址, 其結合了匿名和非匿名位址, 視傳送的訊息而定。Mixed is a third form of addressing which combines Anonymous and NonAnonymous addresses depending on the message that is being sent. 混合模式定址的常見範例是使用專用電腦來處理錯誤或認可訊息。A typical example of mixed-mode addressing is the use of a dedicated machine for processing fault or acknowledgment messages. 如果回復的標準交換順序是 HTTP 或 TCP, 回應會使用匿名定址, 但錯誤會使用非匿名定址。If the standard exchange sequence for replies is HTTP or TCP, the responses use Anonymous addressing but the faults use non-anonymous addressing. 雖然 WCF 不會在其中一個標準系結中提供混合定址功能, 但您可以撰寫通道, 讓服務能夠直接在後端通道 (當回應位址為匿名) 或在不同的通道上傳送回應 (當回應位址是非匿名的)。While WCF does not provide Mixed addressing functionality in one of its standard bindings, it is possible to write a channel that allows the service to send responses directly on the back-channel (when the response address is Anonymous) or on a separate channel (when the response address is NonAnonymous). 在這種情況下, 通道的繫結項目會用來將設定SupportedAddressingMode為 Mixed。In such a case, the binding element of the channel is used to set SupportedAddressingMode to Mixed.