The Rest activity enables users to call REST endpoints or resources when processing workflow data. The activity allows workflows to exchange data with arbitrary REST services. Data sent to a REST service can integrate a workflow with other systems inside and outside the organization. Data received from a REST service can provide decision support information on approval forms. You create flowdata variables to move data between the workflow and the REST service.
The Rest activity has the following properties. Note that most activity properties are ECMAScript expressions, so ensure that you configure each property by clicking the “E” icon in the property field to open the ECMA Expression Builder.
Table 7-29 Rest Activity Properties
Property Name |
Description |
---|---|
Activity Id |
Specify a unique string value that identifies the activity. Activity Ids are written to the user application’s log file. Specifying a meaningful Activity Id makes it easier to understand the data written to the logs. You can specify letters, numbers, and the underscore (_) character. If you do not specify a value, the Activity Id defaults to ActivityNN where the NN represents the order in which the activity was added to the workflow. |
Name |
Provides a name for the activity. |
Protocol |
Specifies the protocol the activity uses when calling the REST server. You can specify either http or https. NOTE:If you specify https, you must also configure the Trust Manager property for the activity. |
Host |
Specifies the REST server the activity calls to request or modify data. |
Port |
Specifies the port number the activity uses when calling the REST server. |
Path |
Specifies the encoded URL path the activity uses when calling the REST server. If the path includes any reserved characters, you must URL encode the path. For more information about URL encoding, see http://en.wikipedia.org/wiki/Percent-encoding. In the ECMA Expression Builder, select URL Path Encoding > URL encode the path and modify the path to include the URL path expression to encode. |
Method |
Specifies the method the activity uses to retrieve data from or modify data on the REST server. The choices are:
|
Authorization Header |
Specifies the Authorization header the activity uses when calling the REST server. In many cases, the REST server expects the header to be in the “Basic Authentication” format. For more information about the “Basic Authentication” format, see http://en.wikipedia.org/wiki/Basic_authentication. If this is the case, in the ECMA Expression Builder, select Basic Auth Header and modify the header to include the username and password used to access the REST server. |
Accept Header |
Specifies the Accept header the activity uses when receiving data from the REST server. The Accept header tells the REST server the format in which it should return data. The activity can receive data in either XML or JSON format. The choices are:
|
Http Headers |
Specifies any additional HTTP headers the activity uses when calling the REST server. Specify both header name and value expressions, as necessary, using quotation marks around each expression. |
Timeout |
Specifies a dynamic expression that defines the period of time, in milliseconds, allotted for the Rest activity to complete. The timeout interval applies each time the activity is executed by the addressee. For details on building ECMA expressions, see Section 9.0, Working with ECMA Expressions. For descriptions of the system variables available in a workflow, see Understanding Workflow Data. |
Trust Managers |
If the activity uses the https protocol, this property specifies one or more trust managers used to authenticate the connection to the REST server. The property expression must evaluate to TrustManager, TrustManager[], or List<TrustManager>. The default choices available in the ECMA Expression Builder are:
|
To bind the data items associated with the Rest activity, you define pre-activity and post-activity mappings. The pre-activity mappings map values retrieved from the flowdata object to attributes in the Input message for the REST server that will be accessed by the Rest activity. The post-activity mappings map the response from the REST server back into the flowdata object.
Table 7-30 Rest Activity Data Item Mappings
Setting |
Description |
---|---|
Pre-Activity |
If the REST service you want to call requires payload data, you need to specify pre-activity mappings. This is normally the case when you use a PUT or POST request. When this option is selected, you can double-click a cell in the Source Expression column to specify where the Rest activity gets data for a particular REST server input field. In particular, you can set a source expression for Content Type and Content, as follows:
|
Post-Activity |
If the REST service returns data you want to capture, you need to specify post-activity mappings. This is normally the case for most requests. When this radio button is selected, you can double-click a cell in the Target Expression column to specify where data from a REST server output field should be copied after the form has been processed. In particular, you can set a source expression for Status Code, Content Type, and Content, as follows:
|
Source Expression |
Specifies a source expression. When you click a cell in the Source Expression column, the ECMA Expression Builder displays to help you define your expression. It is recommended that you click the Map All button to allow Designer to generate this expression for you. |
Target Expression |
Specifies a target expression. When you click a cell in the Target Expression column, the ECMA Expression Builder displays to help you define your expression. It is recommended that you click the Map All button to allow Designer to generate this expression for you. |
Not supported with this activity.