Message Contracts in Workflow Services

The Workflow Designer in Visual Studio 2010 (even with SP1) is really good at driving developers up the wall! I was modifying my ExpenseSample Workflow to directly read a Correlation ID from my Entity and it took me almost the whole morning to figure out what's wrong!

Here's my MessageContract


    [MessageContract(IsWrapped=false)]
    public class SubmitterRequestMessage
    {
        [MessageBodyMember]
        public Expense Expense { getset; }
    }


And I went to set the CorrelatesOn property of my ReceiveActivity. It nicely gave me something like the following:
sm:body()/xg0:SubmitterRequestMessage/xg0:Expense/xg1:WorkflowID

However, when I execute my workflow, it throws an exception. As usual I have to enable WCF tracing to get pass all the useless generic WCF error messages to find out what's the problem. The error message I got was:

A correlation query yielded an empty result set. Please ensure correlation queries for the endpoint are correctly configured.

Then I found this article Troubleshooting Correlation


Turns out there is a bug in the tool which generates the wrong XPath. To fix the problem, I simply need to change it to:
sm:body()/tempuri:Expense/xg1:WorkflowID


and everything works. I don't understand why such things can happen in the best IDE on the planet. I don't understand how such thing can slip through VS's QC and I certainly don't understand why it isn't fixed in SP1.

No comments:

Post a Comment

Popular Post