Version 3.0 - September, 2006
While Activity
Introduction
Deploying the Process
Running the Process

While Activity

Introduction

This sample demonstrates the use of the while activity. In this example, a while activity is used to loop through a sequence of order detail records and calculate the total cost of all of the items in the order. The process consists of:

The diagram below is a visual representation of the process. The process is instantiated when an order message is received. The first assign initializes the number of detail records by using the count() XPath expression, sets the detail index to 1 (XPath arrays are 1-based), and sets the total amount to zero.

The while activity's condition compares the index to the number of order detail records. As long as the index is less than or equal to the number of records, the while activity will execute. Inside the while activity is a sequence containing two assign activities. The first assign adds (item count * item cost) to the order total. The second increments the index.

When the while activity is finished (the index is greater than the number of order detail records), the process continues by executing the assign activity that creates the response message and then replying with the answer.

while example

Deploying the Process

See Deploying the Samples.

Running the Process

See Running the Samples. The service name to use is whileProcessService. The sample data file orderMessage.xml can be used as input for this example.