Ok, so I may be approaching this incorrectly but essentially I'm trying to play with new WF services in 4.0 to build up to a Windows service that hosts a WF service. At the moment I have constructed client (containing a simple Activity XAML) and service (WF service implemented in a XAMLX file) projects.
I have tried simple "hello worlds" for each one. The client has been hosted in a WorkflowApplication
and I initially setup the service as the default WF service project template. Both seem to be fine there.
Since I want to host a service without IIS, naturally my next attempt was to host my service in a WorkflowServiceHost
. Doing this I can use XamlServices.Load()
and pass the object it returns to the WorkflowServiceHost
constructor along with a URI for the endpoint. I was concerned because that there is no Run()
member method like there is in the WorkflowApplication
class. I assumed that the Open()
method would open the service host object as a service and that it would start an instance of the workflow but there is no indication of it.
At first I setup the service workflow to simply write to a text file when it started but nothing happened. I tried to debug with breakpoints but since it is loading a XAMLX file at runtime, VS doesn't allow me to debug the WF. So I tried altering the client project a bit to use a WorkflowServiceHost
instead of a WorkflowApplication
. I used the same workflow used to test out the hello world style workflow and this time there was no output to console and the WorkflowApplication
was successful with that previously.
Here's the very basics of what I did with the client to host the workflow service in the console project. If anyone wants to see the XAML for the workflow let me know and I'll update this question. Here's the hosting code in Main()
.
const String clientAddress = "http://localhost:9998/Client";
WorkflowServiceHost wfHost = new WorkflowServiceHost( new ClientWf(), new Uri(clientAddress) );
wfHost.Open();
while( Console.ReadKey().KeyChar.ToString().ToUpper() != "X" ) { }
wfHost.Close();