HttpWorkflowService

Create a WorkflowService which uses HTTP instead of SOAP activation

Requirements

Priority Description Notes
0 Receive HTTP Messages and deliver them to workflow activities The HttpReceive activity supports request/response with HTTP messaging
0 Support URI Templates The HttpReceive activity uses the UriTemplate class to provide support for template matching and argument binding
0 Support All HTTP Verbs (and custom verbs) The HttpReceive activity supports standard verbs in the drop down list, or type your own custom verb
0 Allow a late bound decision about which XAML files to load The XAML file must be determined at the time the service host is opened for the host to know what UriTemplates can be matched.
0 Support loading XAML files from sources other than the file system You can load from non-file streams if you want by loading an activity and passing it to the HttpWorkflowServiceRoute
0 Support Persistence and Correlation Supports any InstanceStore and Correlation via cookies (now) and content based correlation (soon)
0 Support Durable Timers (not supported yet)
0 Make it simple for WF developers to correctly report errors via HTTP Exception Handling and HTTP Workflow Services
1 Work with Windows Server AppFabric Monitoring not supported yet

Acceptance Tests

Implement the service from the WCF WebHttp REST Entity Service with a workflow and pass all the same tests Implement the service from the article How to GET a Cup of Coffee

Designer UI

This is a screenshot of a prototype
prototype.png

More HttpReceive Designer prototype images

Examples

Design

The behavior of the HTTP Workflow Service is similar to the behavior of a WorkflowService.

Design Time

  1. Workflow Author drops an HttpReceive activity and configures the HTTP Method, UriTemplate
  2. Workflow Author drops activities on the body to deal with the request. They can access the Request and URI Template arguments for processing.
  3. Workflow Author assigns a response to the response argument. For simple cases just assign whatever object you want, it will become object content in the response message. For more complex cases, create a new HttpResponseMessage or HttpResponseMessage<T> this allows you to add headers or other things to the response message.

Runtime Initialization

  1. The host application creates an instance of an HttpWorkflowServiceHost for a given base address and workflow definition
  2. The HttpWorkflowServiceHost then walks the activity tree of the workflow definition and builds a UriTemplateTable for all of the UriTemplates in the workflow
  3. The host application calls HttpWorkflowServiceHost.Open to begin listening for requests

Runtime Request/Response handling

  1. WCF WebApi receives a message which is dispatched to an instance of HttpWorkflowResource to process.
  2. HttpWorkflowResource matches the request to the receive activity using the URI template. If no match is found it returns a (404) Not Found error.
  3. HttpWorkflowResource correlates the message and loads a workflow instance or creates a new one and runs the workflow instance which will run until the receive activity is idle with the given bookmark.
  4. HttpWorkflowResource resumes the bookmark
  5. HttpReceive gets the IHttpWorkflowReceiveContext extension and schedules the Body ActivityFunc with the parameters. The body executes and returns.
  6. HttpWorkflowResource examines the response - if it is an HttpResponseMessage it returns it. Otherwise it wraps the response in a new HttpResponseMessage and returns it. If response is null, the default behavior of WCF WebApi kicks in which is to return an empty response with a OK (200) status code.

Classes

Interfaces

Routing Requests

The HttpWorkflowServiceRoute class provides a means to create a route for requests to a virtual path to be handled by a workflow
protected void Application_Start(object sender, EventArgs e)
{
    // Route requests to /api to the SampleResource.xaml workflow
    RouteTable.Routes.Add(
        new HttpWorkflowServiceRoute("api", Server.MapPath("~/XAML/SampleResource.xaml")));

    // You can also get the activity from another source
    RouteTable.Routes.Add(
        new HttpWorkflowServiceRoute("test", GetActivityFromDatabase()));
}

Correlation

Workflows are correlated by headers or content - see Http Message Correlation

Last edited Sep 29, 2011 at 1:33 AM by ronjacobs, version 23

Comments

mpcoder Feb 28 at 2:17 PM 
any updates on this?

oatkins Sep 28, 2012 at 2:41 AM 
Any news on when we might see this?