.netwcfworkflow-foundation-4asp.net-4.0

Workflow Foundation 4 - DeclarativeServiceLibrary - Error while calling second ReceiveAndSendReply Sequence - VS2010


I have created a DeclarativeServiceLibrary using VS2010 beta 2,
Please check this image of Sequential Service
alt text

Following is the code used to call these two activities ` int? data = 123;

        ServiceReference1.ServiceClient client1 = new ServiceReference1.ServiceClient();
        string result1 = client1.GetData(data);

        //This line shows error :(
        string result2 = client1.Operation1();

        Response.Write(result1 + " ::  ::" + result2);`  

client1.GetData works perfectly, but client1.Operation1 show the following error. Please let me know how to fix this.

There is no context attached to the incoming message for the service and the current operation is not marked with "CanCreateInstance = true". In order to communicate with this service check whether the incoming binding supports the context protocol and has a valid context initialized.


Solution

  • You need to setup some form of correlation to get the second message into the same workflow service instance. There are a couple of ways to do so, either context correlation using one of the correlation bindings, like wsHttpContextBinding, of request correlation where you do the same based on some common data in your messages. The last is the more flexible but it means you need some unique data, like an order number, to be send along with every request.

    Here is a blog post describing how to use message correlation.

    In the UI use the CorrelationInitializer to set correlation with the first Receive activity and use the CorrelatesOn with the second Receive activity.