This project is read-only.

GET Sample Resource Acceptance Test

To complete this test the HTTP Workflow Service must implement the GET Resource method which is implemented in the following code
[WebGet(UriTemplate = "{key}")]
public HttpResponseMessage<Sample> Get(HttpRequestMessage request, string key)
    // Note: Validate your arguments and return BadRequest (400) if invalid

    var resource = repository.Get(ParseResourceKey(key));

    // Note: Return 404 - Not Found if you can't find the resource
    if (resource == null)
        throw new HttpResponseException(HttpStatusCode.NotFound);

    // Note: Check for ETag - return NotModified (304) if match
    CheckIfNoneMatch(request, resource);

    return CreateResponseWithETag(resource);


Step 1: Create the HTTP Workflow Service

Starting from an empty XAML file
  • Drop an HttpWorkflowService
  • Drop an HttpReceive inside of the HttpWorkflowService
  • Set the Properties

Step 2: Create Resource Specific Activities

  • ValidateKey - validates that the key requested is a valid value - throws a BadRequest if not
  • Get from Repository - application specific code to get the requested resource from the repository

Step 3: Create the Service Body

The Service Body makes use of two Microsoft.Activities.Http activities
  • CheckIfNoneMatch - Looks for the presence of an IfNoneMatch header and checks to see if there is an ETag match
  • CreateResponseMessage<T> - Creates a strongly typed response message and optionally adds an ETag header
Note: You can just assign the response delegate out argument if you prefer but this option does not support ETag headers

Step 4: Invoke the Service

GET http://localhost:5401/api/1 HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Referer: http://localhost:5401/
Accept-Language: en-US
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
If-None-Match: "ce7bc2f2-9ef5-46e7-8707-6a8bed84254e"
Host: localhost:5401

HTTP/1.1 200 OK
Server: ASP.NET Development Server/
Date: Thu, 29 Sep 2011 00:43:39 GMT
X-AspNet-Version: 4.0.30319
Set-Cookie: WorkflowInstance=7618106a-a80e-4369-9641-d3f8f9d690ae
Content-Length: 239
ETag: "4269c0d3-63cb-4d42-b5b7-ed27ef9ef44d"
Cache-Control: private
Content-Type: application/xml; charset=utf-8
Connection: Close

<?xml version="1.0" encoding="utf-8"?>
<Sample xmlns:xsi="" xmlns:xsd="">

Last edited Sep 29, 2011 at 1:46 AM by ronjacobs, version 3


No comments yet.