locked
Best practices for integration with async Web client RRS feed

  • Question

  •  

    I am designing a workflow using WF4 that is supposed to be consumed by a Web client. The workflow aggregates WCF services and is triggered by a Receive activity that is in turn spawned from a Web page. While the workflow is being executed, the user's Web session is active, and certain workflow activities may need to inform a user, i.e. Web page needs a feedback about certain workflow stages. I checked the forum and WF samples but have not found examples that would illustrate this approach.

    I would like to stick to WCF-based activities (Send, Receive etc.), but not quite certain how to implement feedback to a Web page. So I will appreciate recommendations for best practices in such case.

    Let's say this is the scenario:

    1. User clicks "Start" button on a Web page to start a workflow.
    2. Workflow service creates a workflow instance and responds with a instance Id.
    3. Next, "DoSomething" activity is executed on a server
    4. When DoSomething is completed, user should be presented a new Web page. 5-NNN. Other activities are executed, some of them also requiring feedback.

    Steps 1-2 can be implemented using ReceiveAndSendReply compound activity that consists of Receive and SendReply. Step 3 is some custom Code activity that completes shortly My first thought about step 4 is that it can be implemented using Send activity, but then Web application should act as a WCF service and provide an endpoint which does not fit a Web client. How else this feedback can be implemented?

    Thanks in advance


    Vagif Abilov
    Monday, October 18, 2010 5:26 PM

Answers

  • Hi, Vagif

    ->"When DoSomething is completed, user should be presented a new Web page."
    Two options come to my mind:
    1. Use javascript in the client page to query the status of workflow. when DoSomething finished, server side database updated. then javascript refresh the page and show the user a new page.

    2. Use Ajax, query the status of workflow, when DoSomething finished ,server side database updated, then javascript update the page asynchronously. and show the user the feedback info.

    Hope this helps.
    Regards


    This posting is provided "AS IS" with no warranties, and confers no rights. Microsoft Online Community Support. My Blog:http://xhinker.com "Microsoft Windows Workflow Foundation 4.0 Cookbook"
    • Marked as answer by Andrew_Zhu Tuesday, October 26, 2010 7:01 AM
    Thursday, October 21, 2010 7:40 AM
  • Hi, Vagif

    The status could be stored in tracking database or in any other storage medium(file,database...). and then expose these status information as a service, say, a Restful WCF service, then javascript can use this Restful service directly.

    Regards
    This posting is provided "AS IS" with no warranties, and confers no rights. Microsoft Online Community Support. My Blog:http://xhinker.com "Microsoft Windows Workflow Foundation 4.0 Cookbook"
    • Marked as answer by Andrew_Zhu Tuesday, October 26, 2010 7:01 AM
    Friday, October 22, 2010 6:39 AM

All replies

  • The Hiring Process sample demonstrates how to connect a workflow to a web interface:

    http://msdn.microsoft.com/en-us/library/ee622985.aspx

     

    Tuesday, October 19, 2010 7:42 PM
  • Patrick,

    Thank you for the answer. Yes, this sample shows how to connect a workflow to a web application, however Web application in this sample only communicates directly with a workflow when starting it (using Receive activity). My question was if a workflow can send a feedback using Send activity. My current understanding is that this would not be possible because then Web application would essentially establish duplex communication with a workflow, and a browser session is not suitable for such things.

    Vagif


    Vagif Abilov
    Wednesday, October 20, 2010 7:56 PM
  • Hi, Vagif

    ->"When DoSomething is completed, user should be presented a new Web page."
    Two options come to my mind:
    1. Use javascript in the client page to query the status of workflow. when DoSomething finished, server side database updated. then javascript refresh the page and show the user a new page.

    2. Use Ajax, query the status of workflow, when DoSomething finished ,server side database updated, then javascript update the page asynchronously. and show the user the feedback info.

    Hope this helps.
    Regards


    This posting is provided "AS IS" with no warranties, and confers no rights. Microsoft Online Community Support. My Blog:http://xhinker.com "Microsoft Windows Workflow Foundation 4.0 Cookbook"
    • Marked as answer by Andrew_Zhu Tuesday, October 26, 2010 7:01 AM
    Thursday, October 21, 2010 7:40 AM
  • Hi Andrew,

    Thank you for the suggestion. I was thinking about using Javascript/Ajax, just wanted to confirm that this is the best (or perhaps the only good) option.

    When you say "query the status" of workflow, you mean to access workflow tracking information? Or perhaps expose a service in between that would expose workflow state, so a Web application does not need to care about workflow tracking database?

    Best regards


    Vagif Abilov
    Thursday, October 21, 2010 2:27 PM
  • Hi, Vagif

    The status could be stored in tracking database or in any other storage medium(file,database...). and then expose these status information as a service, say, a Restful WCF service, then javascript can use this Restful service directly.

    Regards
    This posting is provided "AS IS" with no warranties, and confers no rights. Microsoft Online Community Support. My Blog:http://xhinker.com "Microsoft Windows Workflow Foundation 4.0 Cookbook"
    • Marked as answer by Andrew_Zhu Tuesday, October 26, 2010 7:01 AM
    Friday, October 22, 2010 6:39 AM
  • Thanks a lot for clarification!

     

    Vagif


    Vagif Abilov
    Saturday, October 23, 2010 2:09 AM