views:

265

answers:

3

Is it possible to create a WCF workflow using the standard (Activity template) Workflow activity templates? And, if so, where can I find some samples that DO NOT use the standard WCF service template (WCF Workflow Service template)?

Explanation: I'm trying to discover, load and run workflows at runtime, including workflows with WCF activities. Standard workflows get compiled into types (which makes them easy to discover), however the "WCF Workflow Service" template is an xamlx file, which is added as content and loaded as a manifest stream at runtime. This makes discovery at runtime difficult.

I don't think it is a requirement to use this template to create a service, as the WorkflowServiceHost can take an Activity in its constructor.

I'm trying to keep the task of developing a new WCF service to be discovered, loaded and "executed" (i.e., loaded and listening) at runtime as streamlined as possible.

+1  A: 

Yes it is.

This blog post describes how to use an SVC extension instead of a XAMLX and uses a compiles workflow to do so. The comments add some details how to get rid of the SVC file as well. You need to use the WorkflowServiceHostFactory as the Factory to wire things up. You can also do something similar when self hosting.

Maurice
Thanks. Checking it out...
Will
Did help some, but damn there's alot left unsaid.
Will
+1  A: 

I have been trying to figure out the same since yesterday and now I stumbled upon a workaround. There is no template for simple workflow (xaml) in VS 2010 when adding new item. If you create a WCF WF Application, you get xamlx. I created a Workflow Console application instead, that gave me a xaml file which I copied to my working project. Once this was done, hosting was simple using WorkflowServiceHost.

        string uri = "http://localhost:8008/MyService"; 
        WorkflowServiceHost wsh = new WorkflowServiceHost(new Workflow1(), new Uri(uri));
        ServiceMetadataBehavior metadataBehavior = new ServiceMetadataBehavior();
        metadataBehavior.HttpGetEnabled = true;
        wsh.Description.Behaviors.Add(metadataBehavior);
        wsh.AddServiceEndpoint("IService", new BasicHttpBinding(), uri);
        wsh.Open();
This may seem like a whacked-out question, but is "IService" in your example an actual ServiceContract? I ask because I'm wondering if the contract can be inferred from the workflow definition, or if I have to not only create the workflow but also the interface that defines the contract?
Will
This is the interface that is visible to client from workflow. You can name it anything instead of "IService", you can but don't necessarily have to declare in any .cs file. Either way from exapmles I have seen there's no real implementation of this interface. The real meat is inside the activity code and what is returned back to client from activity context. You should be able to call implemented contracts from code with in the activities.
A: 

Actually I just figured out that "Activity" template in add new item is xaml so no need to create that "Workflow console application" to get a xaml file.

A workflow is technically the same as a composite activity which is why there is no separate new workflow template. The only difference is if you run it as is, ie a worklfow, or reuse it on a workflow making it an activity. Its quite common to create a XAML workflow, test it as is and then drop it on a XAMLX workflow service to expose it through WCF.
Maurice