Aqualogic BPM Process Api: Developer Guide
Aqualogic BPM Process Api: Developer Guide
Developer Guide
Version: 6.0
2 | ALBPM | TOC
Contents
ALBPM Process API.............................................................................................................3
ALBPM Process API................................................................................................................................3
What is PAPI?..........................................................................................................................................3
Process API Usage Scenarios...................................................................................................................3
Process API Architecture Overview.........................................................................................................4
Structure of a Java PAPI Application.......................................................................................................4
Writing Your First Java PAPI Program.....................................................................................................6
Compiling a Java PAPI Program..............................................................................................................9
Running a Java PAPI Program.................................................................................................................9
ALBPM PAPI Web Service................................................................................................11
What is PAPI Web Service?...................................................................................................................11
What's New in PAPI Web Service 2.0?..................................................................................................11
PAPI Web Service Usage Scenarios.......................................................................................................12
PAPI Web Service Architecture Overview.............................................................................................12
Enabling PAPI Web Service...................................................................................................................13
Enabling PAPI Web Service in ALBPM Studio.........................................................................13
Enabling PAPI Web Service in ALBPM Enterprise...................................................................13
Installing PAPI Web Service on a J2EE Application Server......................................................14
PAPI Web Service Examples..................................................................................................................15
Java JAX WS Client Example....................................................................................................15
Running Java JAX WS Client Example.....................................................................................18
PAPI Web Service .NET Client Example...................................................................................19
PAPI Web Service Configuration...........................................................................................................21
PAPI Web Service Configuration Console.................................................................................21
Editing PAPI Web Service Configuration..................................................................................22
Configuring PAPI Web Service Log..........................................................................................23
PAPI Web Service Security Authentication............................................................................................24
Configuring Single Sign On Authentication..............................................................................24
Configuring Username Token Profile........................................................................................25
Configuring HTTP Basic Authentication...................................................................................25
Configuring PRESET Authentication........................................................................................26
ALBPM | ALBPM Process API | 3
What is PAPI?
PAPI is a Java client-server API that allows you to interact with processes deployed on an ALBPM Process Execution
Engine.
PAPI is a Java API a Java API that can be invoked by any Java application written in Java 1.5.
PAPI provides the following operations:
• Create, send and abort process instances
• Select and unselect process instances
• Reassign process instances
• Audit an instance
• Suspend and resume process instances
• Grab and un-grab process instances
• Run intactive and global interactive activities
• Run external tasks
• Send notifications
• Get a list of process instances
• Get a list of deployed processes
• List the activities in a deployed process
• Get the latest version of a deployed process
• Manage views and presentations
• Manage attachments
ALBPM WorkSpace is built on PAPI. All the communication between the WorkSpace and the Process Engine is done
through PAPI.
The complete reference documentation for PAPI is available at
http://edocs.bea.com/albsi/docs60/papi_javadocs/index.html
• A web application that needs to create a process instance in ALBPM with the information entered by the user
• An external application whose execution final result is the execution of an ALBPM process
• An external application that need to perform a search, or to list information about processes in ALBPM
• An external application that needs to trigger the execution of an activity
• Batch or automatic processing of process instances
Although you can use PAPI to replace ALBPM WorkSpace with a similar graphical application interface, consider
customizing ALBPM WorkSpace to suit your needs instead. Replacing ALBPM WorkSpace causes you to lose-and
then to have to rebuild-most of the out-of-the-box functionality WorkSpace provides including, for example, both the
authentication framework and the interactive execution framework.
A ProcessService acts as a factory for ProcessServiceSession objects. To create a session, you must first create
and configure aProcessService.
When you create a ProcessService object, a connection to the Directory Service is established. This connection is
used to load ALBPM's environment configuration information and later to authenticate the user creating the process
service session.
Establish a Session
A ProcessServiceSession represents the dialog between a participant and the Directory Service or one or more
engines.
You need a ProcessServiceSession to manage and obtain information about process instances, participants, views,
and presentations.
To create a ProcessServiceSession you need to provide the valid credentials--for example, the user identifier and
password--of a participant that exists in the Directory Service.
package papidoc.examples;
import fuego.papi.CommunicationException;
import fuego.papi.InstanceInfo;
import fuego.papi.ProcessService;
import fuego.papi.ProcessServiceSession;
import fuego.papi.OperationException;
import java.util.Properties;
try {
ProcessService processService = ProcessService.create(configuration);
The following sequence diagram shows the interaction between the classes used in the example.
ALBPM | ALBPM Process API | 7
To create a ProcessService object you need to invoke the factory method ProcessService.create() from
the class ProcessService passing it the Property object as an argument.
If there is a problem locating the Directory Service, this method throws a CommunicationException , so you need
to call it inside a try-catch block.
try {
ProcessService processService = ProcessService.create(configuration);
//...
} catch (CommunicationException e) {
System.out.println("Could not connect to Directory Service");
8 | ALBPM | ALBPM Process API
e.printStackTrace();
}
try {
//...
ProcessServiceSession session = processService.createSession("user", "password",
"host");
//...
} catch (OperationException e) {
System.out.println("Could not perform the requested operation");
e.printStackTrace();
}
It then iterates over them using those ids to obtain the instances for each process by invoking the method
processGetInstances over the session object.If there is a problem performing any of the requested operations, this
method throws an OperationException , so you need to invoke it inside a try-catch block.
Finally it iterates over those instances invoking the method getId() and prints its result.
try {
//...
System.out.println("Show Instances by process:");
for (String processId : session.processesGetIds()) {
System.out.println("\n Process: " + processId);
for (InstanceInfo instance : session.processGetInstances(processId)) {
System.out.println(" -> " + instance.getId());
}
}
} catch (OperationException e) {
System.out.println("Could not perform the requested operation");
e.printStackTrace();
}
session.close();
ALBPM | ALBPM Process API | 9
Closing a session releases all the resources this session is using. After calling the method close(), the session can no
longer be used. If you try to invoke a method on a closed session, its execution fails and a SessionClosedException
is thrown.
processService.close();
This releases all the resources used by PAPI, clears the caches, deletes the temporary files, and closes the connections
to the Process Engine and the Directory Service.
• Windows:
C:>set CLASSPATH="C:/bea/albpm6.0/enterprise/client/papi/lib/fuegopapi-client.jar"
3. Compile the Java PAPI program using javac (Java Compiler) provided by the JDK:
javac MyFirstPapiApplication.java
These two steps can be merged into one by using the -classpath option when calling the java compiler:
javac -classpath "C:/bea/albpm6.0/enterprise/client/papi/lib/fuegopapi-client.jar"
MyFirstPAPIApplication.java
A file with the extension .class is generated in the directory where you compiled your program.
PAPI classes are contained in the fuegopapi-client.jar JAR file, which is distributed with ALBPM Enterprise
under BEA_HOME/albpm6.0/enterprise/client/papi/lib/fuegopapi-client.jar.
• Windows:
C:>set CLASSPATH="C:/bea/albpm6.0/enterprise/client/papi/lib/fuegopapi-client.jar"
3. Copy the file directory.xml to the location specified in your properties file or in your PAPI program. The file
directory.xml resides in the directory albpm6.0/enterprise/conf.
In the analyzed example the directory.xml file was copied to the directory from where the example is run. This
location is specified in the following lines of code:
4. Run your PAPI program using the java command provided by the JDK:
java MyFirstPapiApplication
This step and step one can be merged into one by using the -classpath option when calling the java command:
java -classpath "C:/bea/albpm6.0/enterprise/client/papi/lib/fuegopapi-client.jar"
MyFirstPAPIApplication
When you run the program you see a list of the deployed processes and their instances. The following lines illustrate
the generated output when executing this program connecting to an engine that has three instances sitting on the deployed
process "Process":
Process: /Process#Default-1.0
-> /Process#Default-1.0/1/0
-> /Process#Default-1.0/3/0
-> /Process#Default-1.0/2/0
ALBPM | ALBPM PAPI Web Service | 11
The next time you start the engine PAPI Web Service application is started. To verify this launch PAPI Web Service
Console.
See Launching PAPI Web Service Console in ALBPM Studio on page 21
The next time you start the engine PAPI Web Service application is started. To verify this launch PAPI Web Service
Console.
See Launching PAPI Web Service Console in ALBPM Enterprise on page 22
4. Click on the "new" icon ( ) next to each of the applications you want to install.
5. Click on the "install" icon ( ) next to each of the applications you want to install.
Attention: This may take several minutes. Do not click any link on the page and do back in your browser until
the page is automatically reloaded. When you click on the icon, ALBPM Process Administrator transfers the
file over to WebLogic's Deployment Manager (by means of ALBPM Deployer) and then WebLogic goes through
the application installation process.
ALBPM | ALBPM PAPI Web Service | 15
The next time you start the server PAPI Web Service application starts. To verify this lauch PAPI Web Service Console.
package example;
import java.net.MalformedURLException;
16 | ALBPM | ALBPM PAPI Web Service
import java.net.URL;
import java.util.Map;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFactory;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.Service;
import com.sun.xml.ws.api.message.Header;
import com.sun.xml.ws.api.message.Headers;
import com.sun.xml.ws.developer.WSBindingProvider;
import stubs.InstanceInfoBean;
import stubs.InstanceInfoBeanList;
import stubs.OperationException_Exception;
import stubs.PapiWebService;
import stubs.PapiWebService_Service;
import stubs.StringListBean;
try {
/////////////////// Initialize the web service client ///////////////////
String endPoint = args[0];
QName qName = new QName("http://bea.com/albpm/PapiWebService",
"PapiWebService");
Service service = PapiWebService_Service.create(new URL(endPoint), qName);
PapiWebService papiWebServicePort = service.getPort(PapiWebService.class);
e.printStackTrace();
}
try {
String endPoint = args[0];
QName qName = new QName("http://bea.com/albpm/PapiWebService", "PapiWebService");
Service service = PapiWebService_Service.create(new URL(endPoint), qName);
PapiWebService papiWebServicePort = service.getPort(PapiWebService.class);
//...
} catch (MalformedURLException e) {
System.out.println("Could not connect to the web service endpoint");
e.printStackTrace();
}
Configure authentication
Before invoking any operation over the web service the client has to authenticate. This example shows how to use JAX
WS with Username Token Profile and HTTP Basic authentication.
addUsernameTokenProfile(papiWebServicePort);
addHttpBasicAuthentication(papiWebServicePort);
The method addUsernameTokenProfile configure Username Token Profile authentication. This method throws
aSOAPException, so you need to call it inside a try-catch block.
This example adds the header programmatically but you can also configure Username Token Profile using Web Services
Interoperability Technologies (WSIT) from Metro Web Services stack. For information about WSIT,
seehttp://wsit.dev.java.
The method addHttpBasicAuthentication configures HTTP Basic authentication by obtaining the request context
and adding it the username and password properties.
After executing this procedure the example program runs. You will see a list of the processes deployed in the running
process engine and below them a list of all the in flight instances in each process.
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Services.Protocols;
using System.Net;
using PAPI_WS2_Sample.papiws;
using Microsoft.Web.Services3.Security.Tokens;
using Microsoft.Web.Services3.Design;
namespace PAPI_WS2_Sample
{
class Program
{
static void Main(string[] args)
{
//Set a custom handler for unhandled exceptions (optional)
AppDomain.CurrentDomain.UnhandledException += Program.UnhandledExceptionHandler;
try
{
/////////////////// Initialize the web service client ///////////////////
}
catch (SoapException e)
{
OperationException oe = new OperationException(e.Message);
throw oe;
}
Configure Authentication
Before invoking any operation over the web service the client has to authenticate. This example uses plain text Username
Token Profile authentication. The authentication mechanism has to match the one you define in WSE 3 policy settings.
The following code creates a username token and sets it as the client credentials. Then it it sets the client security policy
by passing the id of this policy as an argument, to the method SetPolicy.
try {
//...
foreach (string processId in processIds)
{
Console.Out.WriteLine("\n Process: " + processId);
instanceInfoBean[] instances = proxy.processGetInstances(processId);
foreach (instanceInfoBean instance in instances)
{
Console.Out.WriteLine(" -> " + instance.id);
}
}
}
catch (SoapException e)
{
OperationException oe = new OperationException(e.Message);
throw oe;
}
In an Enterpise installation PAPI Web Service's configuration is stored in the papiws.properties file, located under
BEA_HOME/albpm6.0/enterprise/webapps/papiws/WEB-INF. This file contains additional advanced properties
that you can use to tune PAPI Web Service performance. Each of this properties has a comment that describes their
function.
Launch PAPI Web Service console to verify your changes were applied.
Click Launch PAPI Web Services Console to verify your changes were applied.
The next time you start PAPI Web Service the changes made to the log configuration are applied.
3. Edit PAPI Web Service configuration and select the SSO option.
See Editing PAPI Web Service Configuration on page 22
4. Enter the fully qualified name of the class containing the SSO implementation.
The next time you start the PAPI Web Service application, SSO authentication is activated.
ALBPM | ALBPM PAPI Web Service | 25
• Edit PAPI Web Service configuration and select the Username Token Profile authentication option.
See Editing PAPI Web Service Configuration on page 22.
The next time you start PAPI Web Service application, Username Token Profile authentication is activated.
• Configure your web services client to send the Username Token SOAP header when it authenticates against PAPI
Web Service.
The way of doing this depends on the programming language and the stack used to code your client.
For example, for a client using Java JAX-WS stack you need to add the following method, and invoke it before
executing any operation.
• Edit PAPI Web Service configuration and select the HTTP Basic authentication option.
See Editing PAPI Web Service Configuration on page 22
The next time you start PAPI Web Service application, HTTP Basic authentication is activated.
• Configure your web services client to use HTTP Basic authentication when it authenticates against PAPI Web
Service.
The way of doing this depends on the programming language used to code your client.
For example, for a client using Java JAX-WS stack you need to add the following method, and invoke it before
executing any operation.
26 | ALBPM | ALBPM PAPI Web Service
1. Use the ant task managedirectory, to add a PRESET with a valid user and password to the directory.xml file that
corresponds to the PAPI Web Service web application.
The directory.xml file for PAPI Web Service web application is located under
BEA_HOME/albpm6.0/enterprise/webapps/papiws/WEB-INF. This file is a copy of the xml file named after
the Directory Configuration name located under BEA_HOME/albpm6.0/enterprise/webapps/conf.
See managedirectory ant task .
2. Edit PAPI Web Service configuration and enter the PRESET name in the field labeled "Set PRESET ID for PRESET
authentication".
See Editing PAPI Web Service Configuration on page 22
The next time you start the PAPI Web Service application, PRESET authentication is activated.