Workflow Manager 1.0 Http Activities

 

Updated: July 12, 2012

Workflow Manager 1.0 provides a set of messaging activities that allow sending outbound messages to Http services. In general each activity represents one Http verb. This topic provides an overview of these activities.

In this topic

  • Http Activity Common Properties

  • Http Activities

    • Specifying the Request and Response Content

    • Http Headers in DynamicValue

Http Activity Common Properties

The arguments of the Http activities are very similar, but vary depending on what is relevant to the particular Http operation that the activity encapsulates. The arguments of each activity allow specifying the core set of parameters that need to be set in order to successfully invoke an http service, including:

  • Uri of the service

  • Request headers and content

  • Response headers and content

  • Return status code

  • Security token for secure invocations

The following table lists the properties and arguments that are common across all of the Http activities.

Property Description
InArgument<string> Uri The Uri of the request.
InArgument<DynamicValue> RequestHeaders The Http headers of the request message.
InArgument<SecurityToken> SecurityToken Enables a claims-based delegation pattern using the GetS2SSecurityToken activity.

Note: this configures the Http activity to use JsonWebTokens (JWTs) and OAuth2 bearer tokens, and as such can only be used within workflows that are part of a scope secured using S2S. The claims of the caller who instantiates the workflow (i.e. the activation message) are used, and the outbound token is signed using the outbound signing certificate configured for the deployment.
bool RetryOnConnectionFailure Enables automatic retry of requests that fail due to timeout or connection loss using an exponential back-off.
ActivityFunc<HttpStatusCode, DynamicValue, DynamicValue, bool> HttpErrorHandler Enables handling of the retry logic based on a particular HttpStatusCode, response headers, and response content.
OutArgument<DynamicValue> ResponseHeaders The Http headers of the response message.
OutArgument ResponseContent The body contents of the response message.
OutArgument<HttpStatusCode> HttpStatusCode The HttpStatusCode of the response message.

Http Activities

Workflow Manager 1.0 provides a set of messaging activities that allow sending outbound messages to Http services. In general each activity represents one Http verb. The following table lists the Http activities available in Workflow Manager 1.0. All of these activities have the common set of arguments and properties described in Http Activity Common Properties. In addition to these common properties and arguments, some of the activities have additional arguments, as described in the Other Arguments column.

Activity Description Other Arguments
HttpGet GET on an Http service
HttpPost POST to an Http service InArgument RequestContent
HttpPut PUT to an Http service InArgument RequestContent
HttpDelete DELETE to an Http service
HttpMerge First class headers to do an update operation using an eTag InArgument RequestContent

InArgument<String> Etag

Specifying the Request and Response Content

When providing the request and response content you can either pass a primitive object, for example a string, number, or date that will be serialized as the request content, or a DynamicValue.

Http activities have a deep integration with DynamicValue: for requests the provided DynamicValue will be automatically serialized to its Json representation and set as the request content for the Http call. For responses the content returned from the server will be loaded into a DynamicValue (this only works if the response is returned as valid Json).

The following code example shows how to use HttpGet to get information from Netflix into a DynamicValue and use some of its properties within an activity:

Variable<DynamicValue> response = new Variable<DynamicValue>();  
Variable<string> name = new Variable<string>();  
Variable<string> synopsis = new Variable<string>();  
Variable<string> releaseYear = new Variable<string>();  
Variable<string> result = new Variable<string>();  
  
Activity sequence = new Sequence  
{  
    Variables = { response, name, synopsis, releaseYear, result },  
    Activities =  
    {  
        // get the data from Netflix  
        new HttpGet  
        {  
            Uri = "http://odata.netflix.com/Catalog/Titles?$filter=Name%20eq%20'The%20Name%20of%20The%20Rose'",  
            ResponseContent = new OutArgument<DynamicValue>(response)  
        },  
  
        // read some properties from the result  
        new GetDynamicValueProperties  
        {  
            Source = response,  
            Properties =   
            {  
                { "d/results(0)/Name", new OutArgument<string>(name) },  
                { "d/results(0)/Synopsis", new OutArgument<string>(synopsis) },  
                { "d/results(0)/ReleaseYear", new OutArgument<string>(releaseYear) }  
            }  
        },  
  
        // create a new string with the properties read the previous step  
        new FormatString  
        {  
            Format = "{0} ({1}): {2}",  
            Arguments =   
            {  
                new InArgument<string>(name),  
                new InArgument<string>(releaseYear),  
                new InArgument<string>(synopsis),  
            },  
            Result = result  
        }  
    }  
};  

Note

DynamicValue integration with Http activities is supported for services that accept and return content as Json. AtomPub is not currently supported in the DynamicValue integration.

Http Headers in DynamicValue

Http headers are specified as a DynamicValue. To set the headers for an activity, you just need to create an pass a DynamicValue that contains the headers that you want to use.

Variable<DynamicValue> requestHeaders = new Variable<DynamicValue>();  
Variable<DynamicValue> responseHeaders = new Variable<DynamicValue>();  
  
var sequence = new Sequence  
{  
    Variables = { requestHeaders, responseHeaders },  
    Activities =  
    {  
        // setup the headers  
        new BuildDynamicValue  
        {  
            Result = requestHeaders,  
            Properties =   
            {  
                { "Accept", new InArgument<string>("text/plain") },  
                { "Accept-Charset", new InArgument<string>("utf-8") },  
            }  
        },  
  
        // get the data from Netflix  
        new HttpGet  
        {  
            Uri = "https://contoso.com?var1=val",  
            RequestHeaders = requestHeaders,  
            ResponseHeaders = responseHeaders,  
        },  
    }  
};