WF4 Workflow Service:SendParameters和ReceiveParameters

简介:

本文主要介绍如何使用SendParameters和ReceiveParameters的使用,这两个活动允许你在调用服务的时候携带多个参数。 在Workflow Service上主要体现在Send,Receive,SendReply,ReceiveReply活动的Content属性的设置上。

下面的例子将通过使用SendParameters和ReceiveParameters将参数从客户端传到服务端,确认后给客户端发送回复。
 

1.服务端工作流ServiceWF流程设置如下图: 

工作流变量如下:

Name

Type

Scope

Default

servicemsg

String

Sequence

 

para

String

Sequence

 

流程设计如下:

clip_image002

 

使用WorkflowServiceHost宿主工作流如下:

class Program

    {

       static void Main (string[] args)

        {               

            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 1”

Result

String

Sequence

 

 

流程设计如下:

clip_image004

客户端调用程序如下:

class Program

    {       

        static void Main (string[] args)

        {           

            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.结果如下: 

clip_image006

 

 

 

本文转自生鱼片博客园博客,原文链接:http://www.cnblogs.com/carysun/archive/2009/12/11/WF4-SendPara.html,如需转载请自行联系原作者

相关文章
|
7月前
|
Python
【Error】DeprecationWarning: executable_path has been deprecated, please pass in a Service object
【Error】DeprecationWarning: executable_path has been deprecated, please pass in a Service object
124 2
verbose stack FetchError: request to https://registry.npm.taobao.org/md-editor-v3 failed, reason: ce
这篇文章描述了在安装npm包`md-editor-v3`时遇到的淘宝镜像证书过期问题,并提供了解决方案,即通过切换npm镜像源到`https://registry.npmmirror.com/`来解决安装失败的问题。
verbose stack FetchError: request to https://registry.npm.taobao.org/md-editor-v3 failed, reason: ce
|
3月前
Passing Messages to Process
Passing Messages to Process
17 0
|
5月前
解决Flutter报错The named parameter |method ‘xxxx‘ isn‘t defined.
解决Flutter报错The named parameter |method ‘xxxx‘ isn‘t defined.
233 3
|
8月前
|
Kubernetes 容器
【kubernetes】解决k8s1.28.4:"command failed" err="failed to parse kubelet flag: unknown flag: --c...
【kubernetes】解决k8s1.28.4:"command failed" err="failed to parse kubelet flag: unknown flag: --c...
1389 0
|
Docker 容器
docker报错ERROR: for hass “host” network_mode is incompatible with port_bindings
docker报错ERROR: for hass “host” network_mode is incompatible with port_bindings
2942 0
|
网络安全 Windows
解决adb报错“failed to create fdevent interrupt socketpair: Invalid argument“问题
解决adb报错“failed to create fdevent interrupt socketpair: Invalid argument“问题
369 0
解决adb报错“failed to create fdevent interrupt socketpair: Invalid argument“问题
‘Client‘ is not allowed to run in parallel.Would you like to stop the running one?
‘Client‘ is not allowed to run in parallel.Would you like to stop the running one?
600 0
‘Client‘ is not allowed to run in parallel.Would you like to stop the running one?
|
Android开发
【错误记录】前台进程报错 ( Bad notification for startForeground invalid channel for service notification )
【错误记录】前台进程报错 ( Bad notification for startForeground invalid channel for service notification )
1449 0
【错误记录】前台进程报错 ( Bad notification for startForeground invalid channel for service notification )
|
Android开发
【错误记录】Tinker 热修复示例运行报错 ( patch receive fail: /storage/emulated/0/patch_signed_7zip.apk, code: -2)
【错误记录】Tinker 热修复示例运行报错 ( patch receive fail: /storage/emulated/0/patch_signed_7zip.apk, code: -2)
495 0
【错误记录】Tinker 热修复示例运行报错 ( patch receive fail: /storage/emulated/0/patch_signed_7zip.apk, code: -2)