Search code examples
wcfworkflowworkflow-foundationworkflow-foundation-4appfabric

Workflow Foundation 4 Management without using AppFabric


We have a WF4 workflow with a Sequence of Activities as a WCF Service.

CalculateTaxesActivity
CreateOrderActivity
CreditCardAuthorizationActivity
etc.....

Our Admin is using AppFabric to manage it and resume, cancel, terminate the Workflows if needed. But we need to delegate the task of management to the warehouse and we don't want to give access to the servers that are running AppFabric for them to do that.

Is there a way of managing the workflows by using an API or Classes available in the Framework? We want the Warehouse personnel to Track and Resume the workflows if any of them faulted etc...


Solution

  • The AppFabric UI doesn't directly communicate with the workflow or WorkflowServiceHost in most cases but is uses WorkflowControlEndpoint and WorkflowControlClient to do so. You can do the same from your code if you wan to.

    The WorkflowControlEndpoint exposes itself using the NetNamedPipeBinding by default so you will need to change that if you want to accept requests from another machine.

    The WorkflowServiceHost config:

    <service name="MyWorkflow“
             behaviorConfiguration="MyWorkflowBehavior">
      <host>
        <baseAddresses>
          <add baseAddress="http://localhost:8080/MyWorkflow" />
        </baseAddresses>
      </host>
      <endpoint address="" 
                binding="basicHttpBinding" 
                contract="IMyWorkflow" />
      <endpoint kind="workflowControlEndpoint" 
                address="Control" 
                binding="basicHttpBinding" />
    </service>
    

    The client code:

    var instanceId = <<an existing workflow instanceId>>;
    
    var controlBinding = new BasicHttpBinding();
    var controlAddress = 
        new EndpointAddress("http://localhost:8080/MyWorkflow/Control");
    
    var proxy = new WorkflowControlClient(controlBinding, controlAddress);
    
    proxy.Suspend(instanceId);