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
继承
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 在其标准绑定中不提供混合寻址功能, 但也可以编写一个通道, 使服务可以直接在后端通道 (当响应地址为 Anonymous 时) 或单独的通道 (当响应地址不是匿名的)。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). 在这种情况下, 通道的 binding 元素用于设置SupportedAddressingMode为 Mixed。In such a case, the binding element of the channel is used to set SupportedAddressingMode to Mixed.

适用于