WF4 Workflow Service:SendParameters和ReceiveParameters
Posted on 2009-12-11 21:29 生鱼片 阅读(2433) 评论(4) 编辑 收藏 举报本文主要介绍如何使用SendParameters和ReceiveParameters的使用,这两个活动允许你在调用服务的时候携带多个参数。
下面的例子将通过使用SendParameters和ReceiveParameters将参数从客户端传到服务端,确认后给客户端发送回复。
1.服务端工作流ServiceWF流程设置如下图:
工作流变量如下:
Name |
Type |
Scope |
Default |
servicemsg |
String |
Sequence |
|
para |
String |
Sequence |
|
使用WorkflowServiceHost宿主工作流如下:
class Program
{
static void
{
WorkflowService service = new WorkflowService
{
Name = "CaryService",
Body = new cary.ServiceWF()
};
Uri address = new Uri("http://localhost:8080/CaryWFServices");
WorkflowServiceHost host = new WorkflowServiceHost(service, address);
try
{
Console.WriteLine("Opening service...");
host.Open();
Console.WriteLine("Service is listening on {0}...", address);
Console.WriteLine("To terminate press ENTER");
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine("Service terminated with exception {0}", ex.ToString());
}
finally
{
host.Close();
}
}
}
2.客户端工作流ClientWF流程设置如下图:
工作流变量如下:
Name |
Type |
Scope |
Default |
Clientmsg |
String |
Sequence |
“I am a client Message |
Result |
String |
Sequence |
|
客户端调用程序如下:
class Program
{
static void
{
try
{
WorkflowInvoker.Invoke(new cary.ClientWF());
Console.WriteLine("Workflow completed successfully.");
}
catch (Exception e)
{
Console.WriteLine("Workflow completed with {0}: {1}.", e.GetType().FullName, e.Message); }
Console.WriteLine("To exit press ENTER.");
Console.ReadLine();
}
}
3.结果如下: