Built-in activities reference
This article provides a collection of activities that are immediately available.
- action
- GET
- POST
- PUT
- DELETE
- receivePOST
- replyPOST
- Receive-replyPOST
- receiveGET
- replyGET
- receive-replyGET
- while
- for-each
- pick
- assign
- empty
The symbols for each activity description can be found in the Flow language behavior and syntax article.
Action
The Action activity is a generic activity for calling a static operation on a Java™ class. The inputs form the parameters.
<action name="NCName" target="java-class-name" operation="NCName" outputVariable? > control* input* </action>
| Name | Description | Required |
|---|---|---|
target |
Target Java class name | Yes |
operation |
Static method name of target class | Yes |
The following example shows the action activity in tooling:
GET
This activity performs an HTTP GET. It has no input. Its output is the value of the response returned from the service.
<GET target="url-exp" name="NCName" outputVariable="NCName"? > control* </GET>
| Name | Description | Required |
|---|---|---|
target |
An expression that is evaluated to the HTTP URL to do the GET against. | Yes |
outputVariable |
The optional variable into which a copy of the content of the response from the service is saved. | No |
The target attribute supports a relative URL for accessing local HTTP resources based on the Connection API. See the information about using the Connection API for details.
- /
- Relative to the application root.
- ~/
- Relative to the application context root.
- ../
- Relative to parent resource from flow URI.
- ./
- Relative to current resource from flow URI.
The following example shows the GET activity in the Assemble tooling:
You can find an example of the GET activity in the employee demo. See the flow samples for more information.
POST
The POST activity performs an HTTP POST. It has, at most, one input: the body of the post request. Its output is the value of the response returned from the service.
<POST target="url-exp" name="NCName" outputVariable="NCName"? > control* input? </POST>
| Name | Description | Required |
|---|---|---|
target |
An expression that evaluates to the HTTP URL to do the POST against. | Yes |
outputVariable |
The optional variable into which a copy of the content of the response from the service is saved. | No |
The following example shows the POST activity in the Assemble tooling:
You can find an example of the POST activity in the employee demo. See the flow samples for more information.
PUT
The PUT activity performs an HTTP PUT. It has, at most, one input: the body of the put request. Its output is the value of the response returned from the service.
<PUT target="url-exp" name="NCName" outputVariable="NCName"? > control* input? </PUT>
| Name | Description | Required |
|---|---|---|
target |
An expression that evaluates to the HTTP URL to do the PUT against. | Yes |
outputVariable |
The optional variable into which a copy of the content of the response from the service is saved. | No |
The following example shows the PUT activity in the Assemble tooling:
DELETE
The DELETE activity performs an HTTP DELETE. It has no input or output.
<DELETE target="url-exp" name="NCName"> control* </DELETE>
| Name | Description | Required |
|---|---|---|
target |
An expression that evaluates to the HTTP URL to do the DELETE against. | Yes |
The following example shows the DELETE activity in the Assemble tooling:
You can find an example of the DELETE activity in the employee demo. See the flow samples information for details.
ReceivePOST
A receive activity consumes HTTP POST requests sent to the process and matches its optional URL fragment. Note that no two receive activities with the same operation and url value can be activated at the same time.
The output of a receive is the value of the received message. It has no input.
<receivePOST name="NCName" url="relative-url"? outputVariable="NCName"? > control* </receivePOST>
| Name | Description | Required |
|---|---|---|
url |
A string that is a relative URL. If present, this relative URL is used to assist in the matching of incoming messages (for example: url="approve"). The URL of the default receive activity (the starting point of the flow instance) should not be specified, otherwise the flow could not be resolved. | No |
outputVariable |
The optional variable into which a copy of the content of the matching request is saved. | No |
The accepted data format includes parameters from a query string or form-encoded parameters, JSON and XML. The following list provides a range of accepted "Content-Type" in headers and their data type in flow:
- XML
-
text/xml,application/xml, allapplication/.+\+xmlmatches. In type oforg.w3c.dom.Document - JSON
-
application/json,text/x-json,text/json. In Java types likeMap, List, or Object - parameters from query string or form-encoded parameters
-
application/x-www-form-urlencodedIn type ofMap<String, FirstElementList<String>>. If there is noContent-Typeentry in headers, this is the default value. See theFirstElementListsection of the global context for more information.
ReplyPOST
A replyPOST activity provides the response to an HTTP POST request previously matched to a receive activity. At the point the reply activity runs, there MUST be exactly one outstanding receive activity with a matching operation name or a URL value, or both. An outstanding receive activity is one that has been matched to an incoming request but for which a response has not yet been produced.
The input is the value sent in the response. It has no output and, at most, one input. The value of the input is what is sent in the response.
<replyPOST url="relative-url"? view="view"? redirect="redirect-url"? outputUri="GC_URI"? name="NCName"> control* input? </replyPOST>
| Name | Description | Required |
|---|---|---|
url |
Follows the same production rule as in receive. In a reply, it is used to match the outstanding receive activity to which the reply activity is providing a response. |
No |
view |
Specify a view for rendering, (for example, report.gt). See the view renderer section of IBM® WebSphere® sMash for information about creating the view to templatize the output. |
No |
redirect |
Specify redirection. if this attribute is specified, it replies status code 303 and its value is the new request URL. | No |
outputUri |
It the optional attribute to specify where to put the object to the global context for serialization. By default, it is /request/flow/output. In the Groovy template, you can use request.flow.output to get the object. |
No |
You can find this sample in the report demo of the flow samples information.
Receive-replyPOST
A receive-replyPOST activity is a combination of a receivePOST immediately followed by a replyPOST. Its output is the value of the received message. Its input is the same as reply: the value sent in the response.
<receive-replyPOST url="relative-url"? outputVariable="NCName"? redirect="redirect-url"? name="NCName"> control* input? </receive-replyPOST>
| Name | Description | Required |
|---|---|---|
url |
Match the outstanding receive to provide a response. | No |
view |
Specify a view for rendering. | No |
redirect |
Specify redirection of this attribute. | No |
outputUri |
An optional attribute to specify where to put the object in the global context for serialization. By default, it is /request/flow/output. |
No |
outputVariable |
Name and copy of the content of the matching request is saved. | No |
receiveGET, replyGET, and receive-replyGET
These activities are similar to their POST counterparts, but for HTTP GET instead of HTTP POST.
Redirec specifies the redirect URL but reply status code 302.
While
This activity is a structured loop. The condition is evaluated when the loop is activated. If the condition is true, the activities inside the loop are activated (respecting the order of specified by their links). When all activities inside the loop have completed or disabled, the condition is evaluated again. This repeats until the condition evaluates to false, at which point navigation continues based on the links leaving the while activity itself. No links can cross the boundaries of a while loop.
This activity has no input and no output variable.
<while name="NCName" condition="bool-expr"> control* activity+ </while>
The following sample shows the sum of all integers ranging from 1 to 99.
<process name="sample" expressionLanguage="Groovy">
<variable name="i" value="${1}"/>
<variable name="sum" value="${0}"/>
<while name="while" condition="i < 100 ">
<assign name="addI">
<copy from="${sum+i}" to="sum" />
</assign>
<assign name="increaseI">
<copy from="${i+1}" to="i" />
</assign>
</while>
<replyGET name="reply">
<control source="while"/>
<input value="${sum}"/>
</replyGET>
</process>
The following example shows the while activity in the Assemble tooling:
for-each
The foreach activity iterates elements of one list, and performs processing against each of them. It takes a list as input and has nested activities operating on each item in the list. It has no output. Its syntax is shown in the following example:
<for-each name="NCName" itemName="..."? > input control* <activity>+ </for-each>
- There must be exactly one input. Similar to the
foreachstatement in Java™, its value should be an array. A NodeList or a Java object implements the Iterable interface. -
itemNameis an optional name for the item selected in each iterator. Its default value is_item. - There is no output variable of the <for-each> activity.
- Like the
whileactivity, the activities inside <for-each> MUST NOT have acontrol(or input with an activity name as value) that refers to an activity outsidefor-each. Activities outside a <for-each> statement must not have acontrol(or input with an activity name as a value) that refers to an activity inside the <for-each>. These restrictions imply that control dependencies MUST NOT cross the boundaries of a <for-each> iteration. It is always possible to include control links to or from the for-each activity itself, and use variable names, where needed.
The following sample shows a sum of the list [1, 3, 5, 7].
<process expressionLanguage="Groovy" name="add">
<variable name="n" value="${0}" />
<variable name="list" value="${[1, 3, 5, 7]}"/>
<for-each name="foreach" itemName="i">
<input value="${list}"/>
<assign name="sum">
<copy to="n" from="${n + i}"/>
</assign>
</for-each>
<replyGET name="reply">
<control source="foreach"/>
<input value="${n}"/>
</replyGET>
</process>
The result of this flow is 16.
The following example shows the for-each activity in the Assemble tooling:
Pick
A pick activity provides external choice. It contains a variable name and an ordered list of choices, each one corresponding to an external request.
It has no input. Its output is a variable consisting of two parts:
- choice
- The name or index of the choice that is picked.
- message
- The value of the message received by the picked choice, if any.
The first event to occur is the one chosen to determine the value of the choice in the pick's output variable: either the name of the choice if one is present, or the numerical index of the choice. If the choice is based on an incoming message, then the incoming message's body is placed in the message part of the pick's output variable. If the choice itself also specifies a variable, then a copy is placed in that variable as well. You can branch on the choice made in the pick using the value of the choice part of the variable in conditions of links.
<pick name="NCName" outputVariable="NCName"? > control* <choice name="NCName"? url="relative-url-exp"? outputVariable="NCName"? /> + </pick>
A message based choice is functionally equivalent to a receive activity, except that it can not have any links itself, it is activated for the life of the pick, and it stops waiting for a message if and when another choice is taken.
Assign
Assignment allows initialization of variables and copying of values from one variable to another.
The assign activity provides a simple data copying utility. It contains one or more copy elements. The assign activity has no semantics, other than to execute its embedded copy elements in sequence. In particular, there is no implication of atomic behavior or roll-back capabilities.
As an assign can copy from and to multiple locations, it has no implicit input or output. Variables that it reads from and writes to must be explicitly referenced in the body of the activity.
<assign name="NCName"> control* <copy from="expression"? to="expression" >from-expression?</copy>+ </assign>
A copy element can only occur within an assign activity. It cannot be the control or target of a link. A copy element must have from and a to.
| Name | Description | Required |
|---|---|---|
from |
An expression or literal value. | Yes |
to |
A left-hand-side expression identifying a variable, expression or a location within a variable. "${}" is not necessary even if it is an expression. | Yes |
The following sample changes a Yahoo!® top music RSS feed title text with an appended publish date:
<process expressionLanguage="Groovy" name="feedSample">
<receiveGET name="start"/>
<GET name="album" target="http://rss.music.yahoo.com/charts/rssTopAlbums.xml"/>
<assign name="changeTitle">
<copy from="${album.channel.title[0].textContent + album.channel.pubDate[0].textContent}" to="album.channel.title[0].textContent" />
</assign>
<replyGET name="result">
<control source="changeTitle" />
<input value="${album}" />
</replyGET>
</process>
The processor can create some of the structure of the "to" attribute if it does not already exist.
The following example shows the assign activity in the Assemble tooling:
Empty
The empty activity implies no processing other than the navigation implied by its connection to other activities through links. It is provided for the purpose of helping the creation of specific navigational patterns.
The output of an empty activity is null. It has no input.
<empty name="NCName"> control* </empty>