Welcome to Windows Communication Foundation (WCF)
Top Tasks :

WorkflowInvoker (JuneCTP)

File Details
Downloads: 718 File Size: 23.9kB
Posted By: Anonymous Views: 1993
Date Added: Mon, Jul 17 2006

The WorkflowInvoker is a static class to create and invoke a WF Workflow within the WCF Service. In order to use this class, the WorkflowRuntime core must be hosted in the appDomain. The WorkflowInvoker namespace includes WFServiceHostExtension class allowing to attach and configure the workflow runtime services:  

using (System.ServiceModel.ServiceHost host = new System.ServiceModel.ServiceHost(typeof(Pinging)))
{
  // Service extension for WF 
  WFServiceHostExtension extension = new WFServiceHostExtension("WorkflowRuntimeConfig");

  // Add the Extension to the ServiceHost collection
  host.Extensions.Add(extension);

  host.Open();

  Console.WriteLine("Press any key to stop server...");
  Console.ReadLine();
  host.Close();
}

Using the WorkflowInvoker class is straightforward like is shown in the following examples:

public string Ping(Request request)
{
  // Step 1: create workflow invoker
  Type type = typeof(WorkflowTest);
  Guid id = Guid.NewGuid();
  HybridDictionary args = null;
  Invoker invoker = WorkflowInvoker.Create(type, args, id);

  // Step 2: pass request object to the workflow
  invoker.RaiseRequestEvent(request);

  // Step 3: wait for response from workflow
  invoker.WaitForResponse(45);

  // Step 4: response
  string response = invoker.GetResponse();

  return response;
}

public string Ping2(Request request)
{
  return WorkflowInvoker.RequestResponse(typeof(WorkflowTest), request);
}

 The workflow services can be added to the WorkflowRuntime core programmatically or using a config file: 

<configSections>
  <section name="WorkflowRuntimeConfig" type="System.Workflow.Runtime.Configuration.WorkflowRuntimeSection, System.Workflow.Runtime, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  <section name ="LocalServicesConfig" type ="System.Workflow.Activities.ExternalDataExchangeServiceSection, System.Workflow.Activities, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</configSections>

<WorkflowRuntimeConfig >
  <Services>
    <add type="System.Workflow.Activities.ExternalDataExchangeService, System.Workflow.Activities, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
         ConfigurationSection="LocalServicesConfig" />
    <!--<add type="System.Workflow.Runtime.Hosting.ManualWorkflowSchedulerService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>-->
  </Services>
</WorkflowRuntimeConfig>

<LocalServicesConfig>
  <Services>
    <!--<add type="RKiss.WorkflowInvoker.InvokerLocalService, WorkflowInvoker, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />-->
  </Services> 
</LocalServicesConfig>

 

Comments
 

Roman Kiss said:

Please, use the following download link: http://www.codeproject.com/soap/WSTransferWorkflow/WorkflowInvoker.zip
Sun, Jul 15 2007 13:27

Add Comment

Name (required)
Web Site (optional)
Comment (required)
Add

Copyright © 2006 Microsoft Corporation. All Rights Reserved. | Terms of Use | Privacy Statement | Contact Us