WorkflowServices and Context Binding

While preparing for one of my Tech-Ed EMEA talks (SOA303 - Long Running Conversations in Workflow Services 3.5 and 4.0) I decided that it was important to make a point about context binding.  The point is that you don't have to use the context bindings (basicHttpContextBinding, netTcpContextBinding, wsHttpContextBinding)  if you don't have more than one receive activity.

To illustrate the point do the following

  1. Create a new VS 2008 Project (look under the WCF templates for Sequential Workflow Service Library)
  2. Drop a CodeActivity on the body of the ReceiveActivity as shown
  3. Double click on the CodeActivity and add the following code

    private void codeActivity1_ExecuteCode(object sender, EventArgs e)
        ReturnValue = "You entered: " + inputValue.ToString();

  4. Run the app using the WCFSvcHost and WCF Test Client to test it
  5. Enter the value 1 - click on the XML tab and notice the context in the response
  6. Right click on the app.config and launch the WCF config editor
  7. Expand the endpoints and on the first endpoint (not the mex endpoint) change the binding to the basicHttpBinding
  8. Open the IWorkflow1.cs file and change the contract as shown below
    public interface IWorkflow1
  9. Now test your workflow again - this time no context and no need for the context binding as you can see from the response

This is good to know since context exchange places a requirement on apps that want to send a message to your service.  As this little demonstration shows, it isn't necessary if you are using just one receive activity to create your workflow service.

Skip to main content