One of the new, and pretty cool, Windows Workflow Foundation features is the ReceiveActivity that unleashes the power of Windows Communication Foundation to Windows Workflow Foundation. Getting started with a ReceiveActivity is quite simple as long as you start with a sequential Workflow Service Library.
The new service host for Windows Communication Foundation services makes life good as it means you can test a workflow without creating a host application or resorting to IIS.
But sometimes you just want to host the workflow runtime yourself and still use the ReceiveActivity. So how to go about and do that?
For a normal WCF host you would use an instance of ServiceHost but with a ReceiveActivity that isn’t quite going to cut it as the host needs some awareness of WF and ServiceHost is very generic. So instead add a reference to System.WorkflowServices and create an instance of WorkflowServiceHost. The syntax is the same so no surprises there:
WorkflowServiceHost host = new
Console.WriteLine(“Press enter to stop.”);
The app.config contains the runtime configuration but all of it is pretty standard WCF stuff so no surprises:
<?xml version=“1.0“ encoding=“utf-8“ ?>
<service name=“WorkflowConsoleApplication1.Workflow2“ behaviorConfiguration=“WorkflowConsoleApplication1.Workflow2Behavior“>
<add baseAddress=“http://localhost:8731/Design_Time_Addresses/WorkflowConsoleApplication1/Workflow2/“ />
<behavior name=“WorkflowConsoleApplication1.Workflow2Behavior“ >
<serviceMetadata httpGetEnabled=“true“ />
<serviceDebug includeExceptionDetailInFaults=“false“ />