Workflow TV - How To Build Workflow Services with a Database Repository

Play Workflow TV - How To Build Workflow Services with a Database Repository
Sign in to queue


Customers often ask me

How can I store my Workflow Service definitions (xamlx files) in a database with IIS and AppFabric?

On this episode I'll show you how you can create a VirtualPathProvider that enables you to build a Workflow respository with a database.


Ron Jacobs
Twitter: @ronljacobs





Download this episode

The Discussion

  • User profile image
    Enrique GC

    Ron, first of all great post, secondly, maybe not the most accurate tittle, more than loading workflows definitions form the DB (.xaml file content) or any other way that it can  be turned into some string value using the DynamicActivity method i.e:

    var activity = ActivityXamlServices.Load(new StringReade(wokflowToExecute)) as DynamicActivity;

    This is an elegant workaround to implement service partitioning on WF, back in the
    beta I asked something like that

    The "limitation" of one WorkflowServiceHost per WF service is one of the reasons I decided to no
    use WF services on one of our company's main solutions, given the number of services to implement, using WCF routing wouldn't be as practical or maybe not a clean, and using pick activities would be irrational, so we used plain WCF instead.

    Currently we have another interesting scenario and the approach you're following gives me another option on how to handle this situation, so, thanks Ron and keep up the good stuff coming.

  • User profile image

    I don't understand your comment about WorkflowServiceHost being limited.  It is no different than a WCF ServiceHost.  The WCF Service Host will host one service per host.  The WF WorkflowServiceHost will host one workflow per host.

    However, you can have multiple services and workflow services in you web application.  In fact you don't really deal with the WorkflowServiceHost or ServiceHost classes unless you are self-hosting so they are just another part of the infrastructure most of the time.

    • WCF services have a collection of operations
    • WF services also have a collection of operations

    The main difference is that the WF service can enforce a messaging protocol with certain operations being available only at certain times.

    My guess is that if you can build your solution with WCF services you can also build it with workflow services.

  • User profile image

    Hi Ron, I thought about this idea some time ago, the problem that I found is the config file, this kind of file can´t be provided by a VirtualPathProvider, so is needed to use pre-defined configs, losing flexibility with this.
    What do you think about? Do you have some idea or workaround?


  • User profile image

    Can provide a web.config with the VirtualPathProvider?  I didn't know that.

    I wonder if you could support a VirtualDirectory and then place a web.config file in the VirtualDirectory with the config you need if that would work.

    It would be worth a try.

  • User profile image

    Hi Ron, Good post.
    I have almost same kind of requirement in our project, but we are using Oracle 11g. Will Oracle 11g support to store workflow service? If so what are all changes needs to be done?


  • User profile image

    You can store the workflow definitions in Oracle - I'm using Entity Framework 4.1 in my code so you would need a provider that works with Entity Framework.

    However, at this time we do not have a Workflow persistence provider for Oracle.  You won't need this unless your workflows are long running.

  • User profile image

    Thanks for your quick reply.

    Can I implement BPM using State Machine WF?

    Here is the scenario I would like to implement...
    Step 1: Create Purchase Request (PR). State of PR at this stage is "Created".

    Step 2: On Step1, WF should assign a task to "Purchase Manager".

    Step 3: When Purchase Manager logs into to system, in his dashboard this task should be visible. At this stage he will have two actions "Approve" and "Reject".

    Step 4: On click of "Approve", again task should assign to Finance Manager. On click of "Reject" the PR state changes to "Rejected"

    Step 5: When Finance Manager logs in task should be visible in his dashbaord with "Approve" and "Reject" actions.

    Step 6: On click of "Approve" Purchase Request state should change from "Created" to "Approved". On click of "Reject" the PR state changes to "Rejected"

    What do you think about? Will this can be implemented in WF 4.0?


  • User profile image

    Any update on the above?


Add Your 2 Cents