ChannelDispatcher.ManualAddressing 属性

定义

获取或设置一个值,该值指示通道调度程序是否将寻址标头添加到请求-回复消息。

public:
 property bool ManualAddressing { bool get(); void set(bool value); };
public bool ManualAddressing { get; set; }
member this.ManualAddressing : bool with get, set
Public Property ManualAddressing As Boolean

属性值

Boolean

如果代理不添加任何寻址标头,则为 true;否则为 false。 默认值为 false

例外

通信对象处于 OpeningOpened 状态。

通信对象处于 ClosingClosed 状态。

通信对象处于 Faulted 状态。

示例

Uri baseAddress = new Uri("http://localhost:8001/Simple");
ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress);

serviceHost.AddServiceEndpoint(
    typeof(ICalculator),
    new WSHttpBinding(),
    "CalculatorServiceObject");

serviceHost.Open();

IChannelListener icl = serviceHost.ChannelDispatchers[0].Listener;
ChannelDispatcher dispatcher = new ChannelDispatcher(icl);

bool isManualAddressing = dispatcher.ManualAddressing;
Dim baseAddress As New Uri("http://localhost:8001/Simple")
Dim serviceHost As New ServiceHost(GetType(CalculatorService), baseAddress)

serviceHost.AddServiceEndpoint(GetType(ICalculator), New WSHttpBinding(), "CalculatorServiceObject")

serviceHost.Open()

Dim icl As IChannelListener = serviceHost.ChannelDispatchers(0).Listener
Dim dispatcher As New ChannelDispatcher(icl)

Dim isManualAddressing As Boolean = dispatcher.ManualAddressing

注解

只有当 ChannelDispatcher 的实例处于 Created 状态时才可以设置此属性,因为该状态是唯一一个可变且不被释放的状态。

如果要防止客户端将 Message ID 和 ReplyTo 寻址标头添加到请求/响应消息,请将 ManualAddressing 属性设置为 true,以便您的应用程序可以控制这些标头。

适用于