Don’t miss the screen cast video on this same subject available at Content Based Correlation in Workflow 4.0

Content based correlation is used when you send a message out of a long running workflow and need to get a response back later into that same workflow using information contained inside the original message.  In this case, the correlation needs to be stored and made available to match the response message.

Content based correlation is easy to set up and use inside Windows Workflow 4.0.  At a high level you need to do the following:

  1. Create a Correlation Handle variable to use for the correction
  2. Set up this variable and xpath on the Send Activity
  3. Set up this variable and xpath on the Receive Activity

It is that easy! 

Lets take a look at this process step by step.

First, set up a new Variable inside the workflow.  In the picture below, the variable is named OrderCorrelation. 

Using the Type Picker and the Search box on the top right, search for CorrelationHandle.  Select the value under the WorkflowServiceModel as seen below.

Now we use this variable on the Send Activity that needs to set up the correlation.  Select the Send Activity and press F4.  When the properties window opens, go to section 4 – Send Message Correlation.  Here we need to set three values.  First, set the variable in the Correlation Handle box and then select the correct endpoint from the drop down as seen below.

The third value to set on the Send Activity is the XPath values to use for the content based correlation.  Below, we set up an OrderIdQuery with an XPath of //temp:OrderId.  OrderId is the variable name of the value in the output message we want to correlate on.

When it is all done, the Send Message will look like the picture below.

The same process is followed on the Receive Activity.  Make sure to use the same Correlation Handle.  The end result of the Receive Activity is shown below.

 

And you are done!  It is that easy to set up content based correction inside Workflow 4.0.