Export (0) Print
Expand All

CallExternalMethodActivity Class

Defines a workflow communication activity that is used to call a method on a local service. This activity is used to send data from the workflow to the host through the local service.

Namespace:  System.Workflow.Activities
Assembly:  System.Workflow.Activities (in System.Workflow.Activities.dll)

[ActivityValidatorAttribute(typeof(CallExternalMethodActivityValidator))]
public class CallExternalMethodActivity : Activity, 
	IDynamicPropertyTypeProvider

A local service is a class that implements a local service interface (an interface that is marked with ExternalDataExchangeAttribute) and is added to the ExternalDataExchangeService.

NoteNote:

When the external method is called all parameters of the method are cloned. If the parameter types implement ICloneable the Clone method is called or they are serialized and deserialized with a BinaryFormatter.

The following code example shows how to use the CallExternalMethodActivity in a custom activity to call an external method. This code example is part of the Listen SDK sample from the PurchaseOrderWorkflow.Designer.cs file. For more information, see Listen Sample.

[System.Diagnostics.DebuggerNonUserCode()]
private void InitializeComponent()
{
    this.CanModifyActivities = true;
    this.Timeout = new System.Workflow.Activities.CodeActivity();
    this.Delay = new System.Workflow.Activities.DelayActivity();
    this.RejectPO = new System.Workflow.Activities.HandleExternalEventActivity();
    this.ApprovePO = new System.Workflow.Activities.HandleExternalEventActivity();
    this.OnTimeoutEventDriven = new System.Workflow.Activities.EventDrivenActivity();
    this.OnOrderRejectedEventDriven = new System.Workflow.Activities.EventDrivenActivity();
    this.OnOrderApprovedEventDriven = new System.Workflow.Activities.EventDrivenActivity();
    this.POStatusListen = new System.Workflow.Activities.ListenActivity();
    this.CreatePO = new System.Workflow.Activities.CallExternalMethodActivity();
    //  
    // Timeout 
    //  
    this.Timeout.Name = "Timeout";
    this.Timeout.ExecuteCode += new System.EventHandler(this.OnTimeout);
    //  
    // Delay 
    //  
    this.Delay.Name = "Delay";
    this.Delay.TimeoutDuration = System.TimeSpan.Parse("00:00:05");
    //  
    // RejectPO 
    //  
    this.RejectPO.EventName = "OrderRejected";
    this.RejectPO.InterfaceType = typeof(IOrderService);
    this.RejectPO.Name = "RejectPO";
    this.RejectPO.Invoked += new System.EventHandler<System.Workflow.Activities.ExternalDataEventArgs>(this.OnRejectPO);
    //  
    // ApprovePO 
    //  
    this.ApprovePO.EventName = "OrderApproved";
    this.ApprovePO.InterfaceType = typeof(IOrderService);
    this.ApprovePO.Name = "ApprovePO";
    this.ApprovePO.Invoked += new System.EventHandler<System.Workflow.Activities.ExternalDataEventArgs>(this.OnApprovePO);
    //  
    // OnTimeoutEventDriven 
    //  
    this.OnTimeoutEventDriven.Activities.Add(this.Delay);
    this.OnTimeoutEventDriven.Activities.Add(this.Timeout);
    this.OnTimeoutEventDriven.Name = "OnTimeoutEventDriven";
    //  
    // OnOrderRejectedEventDriven 
    //  
    this.OnOrderRejectedEventDriven.Activities.Add(this.RejectPO);
    this.OnOrderRejectedEventDriven.Name = "OnOrderRejectedEventDriven";
    //  
    // OnOrderApprovedEventDriven 
    //  
    this.OnOrderApprovedEventDriven.Activities.Add(this.ApprovePO);
    this.OnOrderApprovedEventDriven.Name = "OnOrderApprovedEventDriven";
    //  
    // POStatusListen 
    //  
    this.POStatusListen.Activities.Add(this.OnOrderApprovedEventDriven);
    this.POStatusListen.Activities.Add(this.OnOrderRejectedEventDriven);
    this.POStatusListen.Activities.Add(this.OnTimeoutEventDriven);
    this.POStatusListen.Name = "POStatusListen";
    //  
    // CreatePO 
    //  
    this.CreatePO.InterfaceType = typeof(IOrderService);
    this.CreatePO.MethodName = "CreateOrder";
    this.CreatePO.Name = "CreatePO";
    this.CreatePO.MethodInvoking += new System.EventHandler(this.OnBeforeCreateOrder);
    //  
    // PurchaseOrderWorkflow 
    //  
    this.Activities.Add(this.CreatePO);
    this.Activities.Add(this.POStatusListen);
    this.Name = "PurchaseOrderWorkflow";
    this.CanModifyActivities = false;

}

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0

Community Additions

ADD
Show:
© 2014 Microsoft