ISendMessageCallback 接口

定义

实现一个回调的接口,该回调将在 SendSendParametersContent 活动在网络上发送消息之前调用。

public interface class ISendMessageCallback
public interface ISendMessageCallback
type ISendMessageCallback = interface
Public Interface ISendMessageCallback

示例

以下示例演示如何在消息在网络上发送之前将接口实现 ISendMessageCallback 到新标头的接口。

class SendInstanceIdCallback : ISendMessageCallback
{
    public const string HeaderName = "InstanceIdHeader";
    public const string HeaderNS = "http://Microsoft.Samples.AccessingOperationContext";

    public Guid InstanceId { get; set; }

    public void OnSendMessage(System.ServiceModel.OperationContext operationContext)
    {
        operationContext.OutgoingMessageHeaders.Add(MessageHeader.CreateHeader(HeaderName, HeaderNS, this.InstanceId));
    }
}

方法

OnSendMessage(OperationContext)

发送服务消息时执行。

适用于