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

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,如需转载请自行联系原作者

相关文章
SAP WM Storage Type Capacity Check Method 5 (Usage check based on SUT)
SAP WM Storage Type Capacity Check Method 5 (Usage check based on SUT)
SAP WM Storage Type Capacity Check Method 5 (Usage check based on SUT)
|
Android开发
【错误记录】前台进程报错 ( Bad notification for startForeground invalid channel for service notification )
【错误记录】前台进程报错 ( Bad notification for startForeground invalid channel for service notification )
1263 0
【错误记录】前台进程报错 ( Bad notification for startForeground invalid channel for service notification )
|
Web App开发
SAP Fiori Launchpad上的错误消息 - User Parameter /UI2/WD_TRKORR_CUST is not maintained
Created by Jerry Wang, last modified on Mar 11, 2015 Issue: You meet with the following error message in Fiori UI:
134 0
SAP Fiori Launchpad上的错误消息 - User Parameter /UI2/WD_TRKORR_CUST is not maintained
Observe and check how filter works in HANA live report
Observe and check how filter works in HANA live report
Observe and check how filter works in HANA live report
Step by step to create web service in Cloud Application studio and bind it to a custom action in sta
I woud like to change this extension field in third party system outside C4C, using web service or OData service. I have created a new action in BO CustomerQuote:
Step by step to create web service in Cloud Application studio and bind it to a custom action in sta
RFC Destination WORKFLOW_LOCAL_001 - User WF-BATCH
RFC Destination WORKFLOW_LOCAL_001 - User WF-BATCH
116 0
RFC Destination WORKFLOW_LOCAL_001 - User WF-BATCH
workflow initialization in webclient ui - Remote call case
workflow initialization in webclient ui - Remote call case
workflow initialization in webclient ui - Remote call case