Search code examples
workflow-foundation-4

Can i run WCF Workflow Service using WorkflowApplication class?


im wondering is it possible to load xamlx wcf workflow from file and run it using WorkflowApplication?

Desired result:

        using (Stream xaml = File.OpenRead("Service1.xamlx"))
        {
            activity = ActivityXamlServices.Load(xaml);
        }
        var workflowApplication = new WorkflowApplication(activity);
        workflowApplication.Run();

Solution

  • Extract the WorkflowService Root and run it on wfApp

    var svc = (WorkflowService)XamlServices.Load("c:\\path\\Service1.xamlx");
    WorkflowApplication wfApp = new WorkflowApplication(svc.Body);
    wfApp.Run();
    

    Still not understanding the reason to run a WorkflowService in a WorkflowApplication. Keep in mind that the inverse(run activity workflow with a receive activity as a WorkflowService) is totally valid.