Cora Knowledge Center

Support

Invoke a WCF Service Activity

Use the API to invoke a WCF Service Activity.

This activity can be placed anywhere in the flow, and consumes any external service that is a WCF (Windows Communication Foundation) service.

object InvokeMethod(Guid workflowId, Guid activityId)
        {
            IWorkflowEngine engine = WorkflowRuntime.Engine;
            AuthenticatedUser user = engine.GetCurrentUser();
            if (user != null)
            {
                WcfServiceConsumerActivity activity = (WcfServiceConsumerActivity)engine.GetService<IWorkflowDefinitionService>()
                    .GetWorkflow(workflowId)
                    .GetActivity(activityId);
                MethodDefinition method = activity.Method;
                return method.CreateInstance(new HttpContextWrapper(HttpContext.Current));;
            }
            else
            {
                return null;
            }
        }