Introduction
The CallExternalMethod
Activity define a Workflow communication activity that is used to call a method on
a local service. This activity is used send data from the Workflow to the host
through a local service. A local service is a class which are implements a local
service interface and added to the ExternalDataExchangeService. The
ExternalDataExchangeService is define as
- It comes under the namespace "System.Workflow.Activities"
- The instance of this class is added to the workflow runtime engine for local services communications to be enabled.
Step 1 : Open Visual Studio.
- Select File->New->Project.
- Select Sequential Workflow Console Application.
- Workflow1.cs [Design] open.


Step 2 : Go to the Toolbox.
- Drag CallExternalMethod Activity.

Step 3 : Go to Solution Explorer and right-click.
- Add-> New Item.
- Select Interface and Add.
- Define [ExternalDataExchange]
- Add the namespace Using System.Workflow.Activities.

Code :
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Workflow.Activities;
namespace call1
{
[ExternalDataExchange]
interface
Interface1
{
void WorkFlowToHost(string
msg);
}
}
Step 4 : Go to Solution
Explorer and right-click.
- Add-> New Item->Class.
- Implements Interface.
- Add Event.

Code :
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Workflow.ComponentModel.Compiler;
using
System.Workflow.ComponentModel.Serialization;
using
System.Workflow.ComponentModel;
using
System.Workflow.ComponentModel.Design;
using
System.Workflow.Runtime;
using
System.Workflow.Activities;
using
System.Workflow.Activities.Rules;
namespace call1
{
class Class1
: Interface1
{
public
event EventHandler<SenddataEventArg>
RaiseEventFromHost;
public void
WorkFlowToHost(string msg)
{
SenddataEventArg arg =
new SenddataEventArg();
arg.Response = msg;
EventHandler<SenddataEventArg>
Senddata = this.RaiseEventFromHost;
if (Senddata !=
null)
{
Senddata(this, arg);
}
}
}
public class
SenddataEventArg :
EventArgs
{
string _response;
public
string Response
{
get {
return _response; }
set { _response =
value; }
}



Join the conversation! Your thoughts help the community grow.