rev 1.0 - 06/2009
Contents
Introduction
Process Overview
Project Setup
Update the process
Deploy the process
Test the process
Summary

Working with Human Tasks

Introduction

This Sample demonstrates how to add a People activity to an existing BPEL Process. It is based upon the Human Approval Completed Orchestration project template which is included with the ActiveVOS Designer. The Human Approval Completed project is the completed version of the Human Approval sample. Both project templates (as well as others) are accessible in the ActiveVOS Designer by creating a new orchestration project and selecting a sample template on the second page of the new orchestration project dialog.

The Human Approval demonstrated how to replace an existing Web Service invoke activity with a People activity. In this case both activities were based on the same Web Service interface. This sample differs because it will demonstrate how to create a new interface (in the form of a WSDL file) for the task rather than reusing an existing interface.

ActiveVOS Designer will help you automatically generate a WSDL from your schemas or sample input/output messages.

Process Overview

This sample will demonstrate how to add a human activity to an existing process. In this example, we’ve decided to add a step requiring manager approval of any loans denied by a Loan Representative. For this, we will test the outcome of the ReviewLoan human activity. If the Loan Representative denies the loan, a task is created for a Manager to review the loan rejection and override it if deemed appropriate.

Project Setup and Review

We will begin by creating a new orchestration project based on the Human Approval Completed orchestration project template.

Create a new Orchestration Project

  1. Select File>New>Orchestration Project.
  2. Enter a name for your project and click Next.
  3. Under ActiveVOS Samples select the Human Approval Completed sample template.
  4. Press Finish.

Review the Human Approval Completed process

Once the project opens in your workspace we highly recommend that you review the project contents and deploy and test the project using the instructions in the cheatsheet that opened when the project was created.  These instructions will walk you through starting the Embedded Server, deploying the loan and partner processes, running the process on the server and how to claim and complete the human task.

After you have reviewed the sample we can start preparing the project for the additional People activity and human task. To start off we'll need to define a new interface for the human task.  We'll let the ActiveVOS Designer generate the WSDL interface using two new sample messages; one message for the task input and the second message to define the task output.

Create the Task Input sample data file

The first step is preparing a message to use as the task input.

  1. Select the sample-data folder and create a new XML File named ManagerRequest.xml.
  2. Paste in the following text and save and close the file.
  3. <?xml version="1.0" encoding="UTF-8"?>
    <loan:ManagerRequest xmlns:loan="http://schemas.active-endpoints.com/sample/LoanRequest/2009/06/ManagerApproval.xsd">
      <loan:loanProcessRequest>
        <loan:loanType>string value</loan:loanType>
        <loan:firstName>string value</loan:firstName>
        <loan:lastName>string value</loan:lastName>
        <loan:dayPhone>string value</loan:dayPhone>
        <loan:nightPhone>string value</loan:nightPhone>
        <loan:socialSecurityNumber>string value</loan:socialSecurityNumber>
        <loan:amountRequested>12345</loan:amountRequested>
        <loan:loanDescription>string value</loan:loanDescription>
        <loan:responseEmail>string value</loan:responseEmail>
      </loan:loanProcessRequest>
      <loan:loanApprovalResponse>
        <loan:responseToLoanRequest>string value</loan:responseToLoanRequest>
        <loan:responseDescription>string value</loan:responseDescription>
        <loan:rejectionReason>
        <loan:reason>string value</loan:reason>
        <loan:description>string value</loan:description>
        </loan:rejectionReason>
      </loan:loanApprovalResponse>
    </loan:ManagerRequest>

Create the Task Output sample data file

It is now time to prepare the task output.

  1. Select the sample-data folder and create a new XML File named ManagerResponse.xml.
  2. Paste in the following text and save and close the file.
  3. <?xml version="1.0" encoding="UTF-8"?>
    <loan:ManagerResponse xmlns:loan="http://schemas.active-endpoints.com/sample/LoanRequest/2009/06/ManagerApproval.xsd">
      <loan:responseToLoanRequest>string value</loan:responseToLoanRequest>
       <loan:responseDescription>string value</loan:responseDescription>
    </loan:ManagerResponse>


Update the process


Generate the WSDL for the new task

In this section we're going to do two things:

  1. Generate a WSDL to define the new task interface
  2. Assign this task to the loanmgrs human task participant group

We can easily accomplish both items using the Participants view.  The participants view displays all service consumers, partner service providers and human task participants for a process. 


Review and Update the ManagerApproval.wsdl


In this section we're going to review the WSDL that was generated and make any changes that we desire.  In our example we modify the generated WSDL slightly to limit the choices that a loan manager can provide when completing a task.  The advantage of making this change will become apparent when we review the task presentation.  Rather than allowing the loan manager to enter any value a drop down list containing only valid choices will be displayed.


Set the properties for the task


Now that we have a task interface defined we can set additional properties about the task.

Use the task in a new People Activity


We're going to use the task defined in the previous section in a new People activity.  However, we are only going to execute this new activity if the loan was declined by the loan rep.  The objective of this section, and the next, is to implement the logic in the following image by adding an If activity to invoke the new ManagerApproval people activity followed by an Assign activity that will map the results of the manager's approval to the process output.  The detailed instructions for implementing this logic follow the image. 


Map the Task output to the process output

The final change we are going to make is to map the output from the human task to the required output for the process.

<loan:loanApprovalResponse xmlns:loan="http://schemas.active-endpoints.com/sample/LoanRequest/2008/02/loanRequest.xsd">
   <loan:responseToLoanRequest>{ $ManagerResponse/types1:responseToLoanRequest/text() }</loan:responseToLoanRequest>
   <loan:responseDescription>{ $ManagerResponse/types1:responseDescription/text() }</loan:responseDescription>
  </loan:loanApprovalResponse>

At this point you may notice that the .bunit files in the test folder contain errors.  This is expected since these test cases no longer match the loanProcessHumanCompleted process that we just changed.  Since this sample is not concerned with simulating the process we can safely delete the files in this folder.  Feel free to create new bunit tests.  The Human Approval orchestration project template documentation and the help system are both valuable resources containing information on this topic.


Deploy the process

Once you have made all the changes to the process we can deploy it and run it on the server.  However, since we added new resources to the project (ManagerApproval.wsdl and the task rendering style sheets) we'll need to update the deployment descriptor so that these resources get deployed to the server.


Test the process

The steps for testing the process are similar to the steps defined in the Human Approval Completed cheatsheet and documentation.  Please refer to those instructions for more detail.  An overview of the steps are listed here:

Start the process


Claim the first Loan Representative task


Claim the Loan Manager's task



Review the process in the list of Active Processes.


You can review the state of the process by selecting it from the list of Active Processes on the ActiveVOS Console.  The following image shows the loanProcessHumanCompleted with process ID of 3001 completed successfully.  You can select the process name or id to drill in to the process for more details.



Summary

This sample described how to add a new Human Task and People activity to an existing process.  The WSDL for the task interface was generated automatically by the ActiveVOS Designer based on sample input and output messages that we created ourselves.  After making a slight modification to the WSDL we updated the task properties and used the task in a new People activity.  Since new resources were added to the process we allowed the ActiveVOS Designer to automatically update the deployment descriptor file to keep it in sync with the BPEL process. Finally we deployed and tested the process live on the Embedded Server.