4.1

Table Of Contents
3 Run the workflow by calling the executeWorkflow operation.
To run a workflow, you pass the workflow attributes to the executeWorkflow operation in the form of a
WorkflowTokenAttribute array.
Running a workflow creates a WorkflowToken object, which represents the instance of the workflow that
runs with the specific input parameters that it receives when it starts.
WorkflowToken token = vsoWebControl.executeWorkflow(workflowId, username, password,
attributes);
In the preceding example, the attributes property is the array of WorkflowTokenAttribute objects created
in Step 2.
Sometimes, workflows require input parameters during their run. In these cases, you can provide
attributes through a user interaction while the workflow is running. You can pass attributes to the
workflow during its run using the answerWorkflowInput operation.
You implemented operations in the Web service client that check user permissions, pass attributes to a
workflow, and run the workflow.
What to do next
Implement operations in the Web services client to interact with workflows while they run.
Interact with a Workflow While it Runs
After the workflow starts, the Web services client can perform various actions in response to events while the
workflow is running.
Prerequisites
You must have implemented operations in the Web service client to run workflows in the Orchestrator server.
Procedure
1 Find running workflows by calling the getWorkflowTokenForId operation.
Calling getWorkflowTokenForId obtains a WorkflowToken object, which contains all of the information about
that specific workflow token.
WorkflowToken onemoretoken = vsoWebControl.getWorkflowTokenForId(workflowTokenId, username,
password);
AllActiveWorkflowTokens[n] = onemoretoken;
The preceding code example obtains a WorkflowToken object from its ID and sets it into an array of running
WorkflowToken objects.
2 Check the status of a workflow token by calling the getWorkFlowTokenStatus operation.
When a workflow runs, an application's main event loop usually concentrates on checking the status of
the workflow at regular intervals. The getWorkflowTokenStatus operation requires an array of the IDs of
the workflow tokens for which it is obtaining the status.
String workflowId = workflows[0].getId();
WorkflowToken token = vsoWebControl.executeWorkflow(workflowId, username, password, null);
String[] tokenIds = { token.getId() };
String tokenStatus = "";
while ("completed".equals(tokenStatus) == false
&& "failed".equals(tokenStatus) == false
&& "canceled".equals(tokenStatus) == false
&& "waiting".equals(tokenStatus) == false) {
Thread.sleep(1 * 1000); // Wait 1s
vCenter Orchestrator Developer's Guide
254 VMware, Inc.