上面我们是使用RequestReplyCorrelationInitializer,我们还可以使用CorrelationScope来完成同样的事情,创建同样的工作流,如下:
static Activity CreateWorkflow()
{
var getDataResult = new Variable<string>();
var send = new Send()
{
OperationName = "GetData",
ServiceContractName = "IService1",
Endpoint = new Endpoint()
{
Binding = new BasicHttpBinding(),
AddressUri = new Uri("http://localhost:8080/GetDataService/")
},
Content = new SendParametersContent()
{
Parameters =
{
{"value", new InArgument<int>(42)}
}
}
};
var receive = new ReceiveReply()
{
Request = send,
Content = new ReceiveParametersContent
{
Parameters =
{
{"GetDataResult", new OutArgument<string>(getDataResult)}
}
}
};
var workflow = new Sequence()
{
Variables = { getDataResult },
Activities =
{
new CorrelationScope()
{
Body = new Sequence()
{
Activities = { send, receive }
}
},
new WriteLine() { Text = getDataResult } }
};
return workflow;
}
作者:生鱼片
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。