Built-in activities reference

This article provides a collection of activities that are immediately available.

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>
Attributes
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:

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>
Attributes
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:

The GET activity

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>
Attributes
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:

The POST activity

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>
Attributes
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:

The PUT activity

DELETE

The DELETE activity performs an HTTP DELETE. It has no input or output.

<DELETE target="url-exp" name="NCName">
  control* 
</DELETE>
Attributes
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:

The DELETE activity in 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>
Attributes
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, all application/.+\+xml matches. In type of org.w3c.dom.Document
JSON
application/json, text/x-json, text/json. In Java types like Map, List, or Object
parameters from query string or form-encoded parameters
application/x-www-form-urlencoded In type of Map<String, FirstElementList<String>>. If there is no Content-Type entry in headers, this is the default value. See the FirstElementList section 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>
Attributes
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>
Attributes
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 &lt; 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:

The while activity in 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 foreach statement in Java™, its value should be an array. A NodeList or a Java object implements the Iterable interface.
  • itemName is 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 while activity, the activities inside <for-each> MUST NOT have a control (or input with an activity name as value) that refers to an activity outside for-each. Activities outside a <for-each> statement must not have a control (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:

Foreach activity in 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.

Attributes of Copy
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:

The assign activity in 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>

Version 1.0.0.3.25591