BEA Logo BEA Collaborate Release 2.0

  BEA Home  |  Events  |  Solutions  |  Partners  |  Products  |  Services  |  Download  |  Developer Center  |  WebSUPPORT

 

   Collaborate Documentation   |   Workflows   |   Previous Topic   |   Next Topic   |   Contents   |   Index

Starting Collaborative Workflows

 

The following sections explain how to define start actions for collaborative workflows:

 


About Starting Collaborative Workflows

The job of starting collaborate workflows comprises two tasks:

The following two sections describe the design and programming implications of each task.

Defining Collaborative Workflow Start Properties

There are three ways in which you can start a collaborative workflow:

You define the start properties for a workflow based on the type of workflow being designed (conversation initiator versus conversation participant) and according to the following rules:

Note: To instantiate any workflow, the workflow template definition must be active and not expired.

Starting the Collaborative Workflow at Run Time

How you start a collaborative workflow at run time typically depends on whether the workflow is a conversation initiator or conversation participant:

 


Starting a Conversation Initiator Workflow

A conversation initiator workflow is started in one of the following ways:

Conversation initiator workflows that are started programmatically must have a manual start property defined in the Start node. For more information about starting a conversation initiator workflow programmatically, see Developing Applications that Start Conversation Initiator Workflows.

Conversation initiator workflows that are started via another local workflow must have the called start property defined in the Start node. The local workflow—in the design pattern used in the WebLogic Collaborate sample applications, this local workflow is called a private workflow—starts the conversation initiator workflow as a subworkflow. For more information about the WebLogic Collaborate sample applications, see Using BEA WebLogic Collaborate Samples.

To define the start property for a conversation initiator workflow:

  1. Display or add the start shape, as described in Working with Workflow Components in Using the BEA WebLogic Process Integrator Studio.

  2. Double-click the start shape to display the Start Properties dialog box.

    Figure 3-1 Start Properties Dialog Box: Manual Start


     

  3. Change the text in the Description field to a unique, identifiable name, if desired.

  4. If the workflow will be started programmatically, select Manual. If the workflow will be started via another workflow, select Called.

    For more information about these options, see Working with Workflow Components in Using the BEA WebLogic Process Integrator Studio.

  5. Click OK.

 


Defining the Start Node for a Conversation Participant Workflow

A conversation participant workflow is started when it receives an initial business message from a trading partner. You must define a Business Message start state for such workflows.

To define the Business Message start state for a conversation participant workflow:

  1. Display or add the start shape, as described in Working with Workflow Components in Using the BEA WebLogic Process Integrator Studio.

  2. Double-click the start shape to display the Start Properties dialog box.

  3. In the Start Properties dialog box, select Event, and in the drop-down list that appears to the right, select Business Message.

    Figure 3-2 Choosing a Business Message Start State


     

    The Start Properties dialog box is displayed again with the additional fields, shown in the following figure. In these fields you add information specific to the collaborate workflow, particularly information related to the business protocol on which the workflow is based. (The following figure shows the Start Properties dialog box for a workflow based on the XOCP protocol.)

    Figure 3-3 Start Properties for a Conversation Participant Workflow


     

  4. Change the text in the Description field to a unique, identifiable name.

  5. Provide the information required by the business protocol on which the workflow is based, described in the following sections:

  6. Specify a start organization, as described in Working with Workflow Components in Using the BEA WebLogic Process Integrator Studio.

  7. Click OK.

Starting Conversation Participant Workflows Based on the XOCP 1.1 Protocol

In the Start Properties dialog box, enter the following information for workflows based on the XOCP 1.1 protocol.


 

  1. The target variable is a WebLogic Process Integrator object variable that will contain an instance of an internal type that, in turn, contains the business message.

  2. The router expression is a WebLogic Process Integrator string variable containing the router expression that was set by the sender of the business message.

  3. The sender name is a WebLogic Process Integrator string variable that contains the name of the trading partner who sent the business message.

    If you want to specify that the sender name is to be converted to an XPath expression, select the XPath Conversion button.

Starting Conversation Participant Workflows Based on the RosettaNet 2.0 Protocol

In the Start Properties dialog box, enter the following information for workflows based on the RosettaNet 2.0 protocol.


 

  1. The content variable is a WebLogic Process Integrator XML variable that contains the business message content.

  2. The attachment descriptor variable is an optional WebLogic Process Integrator XML variable that contains XML data that describes the attachment files to the business message.

For complete details about creating start properties for workflows based on the RosettaNet 2.0 protocol, see Implementing RosettaNet for BEA WebLogic Collaborate.

Starting Conversation Participant Workflows Based on the RosettaNet 1.1 Protocol

In the Start Properties dialog box, enter the following information for workflows based on the RosettaNet 1.1 protocol.


 

The content variable is a WebLogic Process Integrator XML variable that contains the business message content.

For complete details about creating start properties for workflows based on the RosettaNet 1.1 protocol, see Implementing RosettaNet for BEA WebLogic Collaborate.

 


Defining the Start Public Workflow Action

You can use the Start Public Workflow action to start a collaborative workflow from a parent workflow. When you use the Start Public Workflow action, you need to specify the following:

When you start a collaborative workflow via the Start Public Workflow action, that collaborative workflow must include a means to synchronize the collaborative workflow with the parent workflow.

The sections that follow explain how to define the Start Public Workflow action and how to synchronize the called collaborative workflow with the parent workflow.

Defining the Start Public Workflow Action

The Start Public Workflow action can be associated with any workflow nodes, but typically is associated with a task node. You must explicitly add the Start Public Workflow action to the workflow template definition.

Adding a Start Public Workflow Action

To define the Start Public Workflow action for a parent workflow in the WebLogic Process Integrator Studio:

  1. Open the workflow in which you want to add the Start Public Workflow action, making sure that the workflow is active and not expired.

  2. In any dialog box where you can specify an action (typically in a task node), click Add to display the Add Action dialog box.

    Figure 3-4 Add Action Dialog Box


     

  3. Click the Integration Actions folder to expand it.

    Figure 3-5 Add Action Dialog Box with Integration Actions


     

  4. Click the WebLogic Collaborate folder to expand it.

  5. Select Start Public Workflow.

  6. Click OK to display the Start Public Workflow dialog box.

    Figure 3-6 Start Public Workflow Dialog Box


     

  7. Complete the following sections on the Conversation page of the Start Public Workflow dialog box. The values and variables you specify in this page uniquely identify the collaboration agreement that contains the workflow required for the conversation.

    Table 3-1 Sections on the Conversation Page

    Dialog Box Section

    Description

    Conversation

    Enter the following:

    Parties

    The name and business type of the parties configured in the collaboration agreement for the associated conversation definition to which the workflow applies. You do not need to specify all the parties, but you must identify enough to uniquely identify the collaboration agreement associated with the workflow.

    The information you provide for business type, if specified, must match the business type description configured for the corresponding trading partner in the WebLogic Collaborate repository.

    You can use the Expression Builder to specify party values in the Start Public Workflow dialog box. For more information, see Using the Expression Builder to Specify Values in the Start Public Workflow Dialog Box.

    Notes

    Optional descriptive text.

    Actions

    Tab in which you can add workflow actions. In the Actions tab, you typically add the "Mark Task as Done" property to synchronize the public workflow with the parent workflow. For more information, see Synchronizing the Child Workflow With the Parent Workflow.


     

  8. Select the Workflow tab. The following page is displayed.

    Figure 3-7 Workflow Page of the Start Public Workflow Dialog Box


     

  9. Complete the following fields and sections of the Workflow tab, which identify both the variable that will contain the workflow instance ID of the child workflow and the variables passed between the parent and child workflows.

    Table 3-2 Fields and Sections of the Workflow Tab

    Field or Section

    Description

    Reference via

    The WebLogic Process Integrator String variable name that will contain the instance ID of the child workflow. You use this variable as a means to implement a standard WebLogic Process Integrator communication mechanism between the parent and child workflows.

    Parameters

    The variable names (in the Name column) and their respective values (in the Expression column) to be passed from the parent workflow to the child workflow. The variable names that you specify here must also be specified as input variables to the respective child workflow. As explained in About Working with WebLogic Process Integrator Variables for Workflows, you should define these variables in both the parent and child workflows before you select them in this dialog box. This ensures that the variables chosen have the correct name and type.

    You can use the WebLogic Process Integrator Expression Builder to create an expression for each variable's value. For more information about using the Expression Builder, see Using the Expression Builder to Specify Values in the Start Public Workflow Dialog Box.

    Results

    Output variable names and their respective values to be passed from the child workflow back to the parent after the child workflow has completed its execution. As with input variables, these output variables should be defined in both the parent and child workflows before you select them in this dialog box.

    Notes

    Optional descriptive text.


     

  10. Click OK to save your changes.

Using the Expression Builder to Specify Values in the Start Public Workflow Dialog Box

You can use the Studio Expression Builder to specify the following values in the Start Public Workflow dialog box:

To display the Expression Builder, right-click in the cell in which you specify one of the preceding values and choose Expression. The Expression Builder is displayed, as shown in the following figure.

Figure 3-8 Studio Expression Builder


 

For information about how to use the Expression Builder, see Using Expressions and Conditions in Using the BEA WebLogic Process Integrator Studio.

Synchronizing the Child Workflow With the Parent Workflow

As mentioned in Defining the Start Public Workflow Action, when you start a collaborative workflow via the Start Public Workflow action, you must have a means of synchronizing that collaborative workflow with the parent workflow. You can do this in either of two ways:

 


Developing Applications that Start Conversation Initiator Workflows

You can start a conversation initiator workflow at run time via a Java application. The following sections describe how to start a conversation initiator workflow programmatically:

To start a conversation initiator workflow programmatically, the start node for the workflow template must have a Manual start property, as described in Starting a Conversation Initiator Workflow.

Note: In Release 2.0 of WebLogic Collaborate, attempting to start a collaborative workflow via the Worklist component of WebLogic Process Integrator results in an error.

WebLogic Process Integrator Integration API

WebLogic Process Integrator applications use the com.bea.b2b.wlpi package, also known as the Integration API, to start WebLogic Process Integrator workflows. This package provides the following interface and classes.

Table 3-3 Components of the com.bea.b2b.wlpi Package

Object

Description

MessageManipulator interface

Implemented by all classes that are used in a Manipulate Message action inside a WebLogic Process Integrator task

WorkflowInstance class

Represents a running workflow instance

WLPIException class

Thrown by a public method of the Integration API if an error occurs with WebLogic Process Integrator processing


 

For details about this package, see the BEA WebLogic Collaborate Javadoc.

Programming Steps for Accessing Conversation Initiator Workflows

To access a WebLogic Process Integrator conversation initiator workflow, a WebLogic Process Integrator workflow application completes the following steps:

The workflow application also needs to handle exceptions thrown by each of the method invocations on the Integration API, as explained in Handling Exceptions.

Note: Before creating an application that starts a workflow, verify the following:

Step 1: Import the Necessary Packages

To access a WebLogic Process Integrator workflow, a WebLogic Process Integrator application begins by importing the necessary package(s). At a minimum, the WebLogic Process Integrator application must import the com.bea.b2b.wlpi package, as shown in the following example.

Listing 3-1 Importing the com.bea.b2b.wlpi Package

import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.naming.*;

import com.bea.wlpi.common.*;
import com.bea.b2b.wlpi.*;

import com.bea.eci.logging.*;

Step 2: Create a Workflow Instance Object for a Specific Workflow Template

The WebLogic Process Integrator application next needs to create a workflow instance object of a specific workflow template definition via an invocation on the startWorkflow method, as shown in the following example.

Listing 3-2 Creating a Workflow Instance Object

WorkflowInstance wi = startWorkflow(); 

Step 3: Initialize Input Variables

If input variables are defined for a conversation initiator workflow, you must initialize and assign values to them in the WebLogic Process Integrator application before starting the workflow instance. These input variables must first be declared in the template definition in the Studio, as described in About Working with WebLogic Process Integrator Variables for Workflows.

A WebLogic Process Integrator application sets instance variables by calling the setVariable method on the workflow instance and passing it the name and value of the variable. The setVariable method requires the following parameters.

Table 3-4 Parameters for the setVariable Method

Parameter

Description

name

Name of the variable to be set.

value

Value for the variable. The value must be represented as a Java object, as described in Associations Between WebLogic Process Integrator Variables and Java Data Types.


 

The following example shows how to use the setVariable method to specify values for two variables in the workflow to be started.

Listing 3-3 Setting the Value of Input Variables

wi.setVariable( INTEGER_ONE_VAR, new Long( 3 ) );
wi.setVariable( INTEGER_ONE_VAR, new Long( 5 ) );

Step 4: Start a Workflow Instance

After creating a workflow instance and initializing input variables, a WebLogic Process Integrator application starts the workflow instance by invoking the start method on the instance object, as shown in the following example.

Listing 3-4 Start a Workflow Instance

wi.start();

Step 5: Wait for the Workflow Instance to Complete

Once a workflow instance has been started, a WebLogic Process Integrator application can wait for its completion by calling the waitForCompletion method on the workflow instance. The operation blocks until the workflow instance has completed.

Listing 3-5 Waiting for Completion of the Workflow Instance

wi.waitForCompletion();

While waiting for the workflow instance to complete, a WebLogic Process Integrator application can determine the completion state of the workflow instance by invoking the isCompleted method on the workflow instance. This method returns a Boolean true if the execution of the workflow is complete, or false if it is not.

Step 6: Handle Results in Output Variables

After a workflow instance has completed, a WebLogic Process Integrator application can handle the results of the workflow instance by retrieving the information stored in output variables. These output variables must first be declared in the template definition in the WebLogic Process Integrator Studio.

A WebLogic Process Integrator application retrieves the value of an instance variable by calling the getVariable method on the workflow instance and passing it the name of the variable to be retrieved, as shown in the following example listing.

Listing 3-6 Retrieving the Results in Output Variables

product = (String)wi.getVariable(MULTIPLY_REPLY_VAR);
note = (String)wi.getVariable(NOTE_VAR);

The getVariable method returns a Java object that should be cast to the appropriate Java data type. For information about the Java types to which you must cast the return values, depending on the corresponding WebLogic Process Integrator variable types, see Using the BEA WebLogic Process Integrator Studio.

Handling Exceptions

If an error occurs while a workflow application is running, a com.bea.b2b.wlpi.WLPIException is thrown. With each method invocation on the Integration API, workflow applications can catch this exception and process it as appropriate, as shown in the following listing.

Listing 3-7 Handling WLPIExceptions in Workflow Applications

catch (WorkflowException we){    
debug("Error starting workflow");
we.printStackTrace();
}

 

back to top previous page next page