invoking other workflow from main workflow dynamically RRS feed

  • Question

  •  Been doing research for a whlie now and while I suspect I passed right by the answer, it wasn't obvious -- so, figured a direct question is best

    I have a situation where I have multiple vendors I do business with and the list can change.  I'd like to be able to create a new workflow for each vendor where I want to support custom steps.  Let's say it is placing an order, and I have a default process that involves manual work.

    I envisioned a file (say XML) where I can have a name which represents the workflow I want to invoke.

    In my main workflow I wanted to have a parallel activity that sent a message to all of the vendor workflows (on my machine) and waited for them all to finish before moving on.

    So, my questions

    1. What do I need to do to send a message to this vendor specific workflow?  I have it's name and I can build out a URI based on the name.  In other words, how can I make this work

    2.  Does this vendor workflow just have to reply to the receive to indicate "I'm done" to the main workflow

    Thanks in advance for pointers, etc.


    Friday, October 22, 2010 12:42 AM


  • What is the host type for your main workflow, and for the vendor workflows? Are they workflow services hosted in WorkflowServiceHost, or hosted by WorkflowApplication or WorkflowInvoker? (Sounds like workflow services since you mention "reply to the receive")

    If WorkflowServiceHost/Workflow Services, you could use a ParallelForEach to iterate your list of vendor workflows, and then for each one, you could invoke the creating operation on the service(do they all have the same service operations or is each one different?). For each of these parallel branches you could initialize correlation using the vendor Id or some unique combo of data that would allow this message to be mapped back to this instance when the vendor work is done. The vendor workflow could have a Send activity at the end that invokes the "I'm Done" operation back on the main workflow.

    How to send the message to the specific vendor workflow with just the URI? Do you have a service reference to the service/services that implement the client workflows? Can you tell a little bit more about the client workflows?

    To signal back to the main workflow that the vendor workflow is done, they can just use a Send activity to call back to the main workflow and let it know. If the vendors are short running you could just use a Receive/SendReply with the appropriate activities in-between, but if the vendor workflow are long running then you would want to reply right away, and then go about doing the long work, and then use Send to send back the I'm done message. You can look at the Document Approval process sample to get some examples of this sort of thing.

    Does this info help? I am not sure if this is what you were looking for, please reply back with additional details if it is not.


    Steve Danielson [Microsoft]
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm


    • Proposed as answer by Andrew_Zhu Monday, October 25, 2010 5:49 AM
    • Marked as answer by Andrew_Zhu Friday, October 29, 2010 7:29 AM
    Friday, October 22, 2010 3:25 PM