IReceiveMessageCallback.OnReceiveMessage 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
收到服务消息时执行。
public:
void OnReceiveMessage(System::ServiceModel::OperationContext ^ operationContext, System::Activities::ExecutionProperties ^ activityExecutionProperties);
public void OnReceiveMessage (System.ServiceModel.OperationContext operationContext, System.Activities.ExecutionProperties activityExecutionProperties);
abstract member OnReceiveMessage : System.ServiceModel.OperationContext * System.Activities.ExecutionProperties -> unit
Public Sub OnReceiveMessage (operationContext As OperationContext, activityExecutionProperties As ExecutionProperties)
参数
- operationContext
- OperationContext
接收消息时所在的操作上下文。
- activityExecutionProperties
- ExecutionProperties
工作流中可用的执行属性的集合。
示例
下面的示例演示如何实现用于在收到消息时访问消息标头的 IReceiveMessageCallback 接口。
class ReceiveInstanceIdCallback : IReceiveMessageCallback
{
public const string HeaderName = "InstanceIdHeader";
public const string HeaderNS = "http://Microsoft.Samples.AccessingOperationContext";
public void OnReceiveMessage(System.ServiceModel.OperationContext operationContext, System.Activities.ExecutionProperties activityExecutionProperties)
{
try
{
Guid instanceId = operationContext.IncomingMessageHeaders.GetHeader<Guid>(HeaderName, HeaderNS);
Console.WriteLine("Received a message from a workflow with instanceId = {0}", instanceId);
}
catch (MessageHeaderException)
{
Console.WriteLine("This message must not be from a workflow.");
}
}
}