May 5, 2008

CallExternalMethod

A workflow can use a activity of type CallExternalMethod. This method is a member of type which addressed with ExteranlDataExchange attribute. To make the method call useful, the parameter of the method should be the information that need to send to client. So the workflow should be responsible to supply the parameters.

At the host side, the workflow runtime should have the provide the ExternalDataExchangeService and the service should have a service which implement the agreed interface. The workflow instance will ask the workflow runtime for an instance implementing the agreed type. After that the workflow instance should construct the parameter and call that method with the parameter.

WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(WorkflowLib.Workflow1));
//
ExternalDataExchangeService xchangeSvc = new ExternalDataExchangeService();
workflowRuntime.AddService(xchangeSvc);
CustomerService custSvc = new CustomerService();
xchangeSvc.AddService(custSvc);