aron
aron

Reputation: 1904

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();

Upvotes: 0

Views: 1186

Answers (2)

Davi Fiamenghi
Davi Fiamenghi

Reputation: 1265

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.

Upvotes: 3

Davi Fiamenghi
Davi Fiamenghi

Reputation: 1265

WorkflowApplication was not made to expose endpoints. Use WorkflowServiceHost instead

WorkflowServiceHost host = new WorkflowServiceHost(activityLoadedFromXaml, baseAddress);
host.Description.Behaviors.Add(new System.ServiceModel.Description.ServiceMetadataBehavior() { HttpGetEnabled = true });
host.AddDefaultEndpoints();

host.Open();

Upvotes: 0

Related Questions