Is it possible to create workflows dynamically? I need to generate a WF dynamically based on a set of business logic and service execution sequence I get as input to the system. Is it possible for me to generate the workflow.xaml dynamically without using the wf designer and execute in the cloud ?
views:
34answers:
1
+2
A:
Yes - you can create xaml file using simple file I/O routines or XML manipulation libraries but the best bet would be using XamlXmlWriter class.
Once workflow xaml is ready, you can execute it using (as sighted in this article)
WorkflowInstance instance = runtime.CreateWorkflow(
XmlTextReader.Create("..\\..\\WorkflowInXML.xml"));
instance.Start();
You can also load activities from xaml in WF4 - check this article for the same.
VinayC
2010-09-17 09:52:01
Thank you very much. This is very helpful for my work.
Kumaripaba
2010-09-17 11:34:01
The code example and the MSDN article is about WF3 and has no relation to workflow 4. The ActivityXamlServices is the way to go in WF4.
Maurice
2010-09-19 12:51:11
@Maurice - yes, the article is dated but the method (CreateWorkflow) still exists and relevant - thats why I have quoted it. It must be noted that ActivityXamlServices allows to load only activity tree and not complete workflow.
VinayC
2010-09-20 05:02:56