BEA Logo BEA WebLogic Collaborate Release 1.0

  Corporate Info  |  News  |  Solutions  |  Products  |  Partners  |  Services  |  Events  |  Download  |  How To Buy

 

   WebLogic Collaborate Doc Home   |   Developer Guide   |   Previous Topic   |   Next Topic   |   Contents   |   Index

Using Workflows to Exchange Business Messages

 

You can use WebLogic Process Integrator workflows to exchange XOCP business messages in the WebLogic Collaborate environment. WebLogic Process Integrator accelerates application development by providing a visual design tool for designing workflows (process models); a run-time Process Engine for executing workflows; and process monitoring capabilities. Using WebLogic Process Integrator in the WebLogic Collaborate environment involves a combination of design, programming, and administrative tasks.

The following sections describe how to exchange business messages in WebLogic Collaborate by using WebLogic Process Integrator workflows:

The WebLogic Process Integrator Verifier program provides an example of using WebLogic Process Integrator workflows to exchange business messages in WebLogic Collaborate. For more information, see Running the WebLogic Process Integrator Verifier Example in BEA WebLogic Collaborate Getting Started.

 


About Using Workflows

The following sections describe key concepts for using WebLogic Process Integrator workflows in WebLogic Collaborate applications:

About This WebLogic Process Integrator Version

The version of WebLogic Process Integrator that is bundled with WebLogic Collaborate provides all of the functionality of WebLogic Process Integrator version 1.2, which ships separately. It also provides additional functionality for integrating with the WebLogic Collaborate environment, including:

For more information about the WebLogic Process Integrator application, see the following documents:

Architectural Overview

This section describes how WebLogic Process Integrator integrates with the WebLogic Collaborate architecture.

Architecture Diagram

The following figure shows the WebLogic Collaborate c-enabler architecture with WebLogic Process Integrator components.

Figure 2-1 C-Enabler Architecture

WebLogic Process Integrator is started automatically upon c-enabler startup.

WebLogic Process Integrator Components in WebLogic Collaborate

WebLogic Collaborate provides the following WebLogic Process Integrator components:

Table 2-1 WebLogic Process Integrator Components

Component

Description

WebLogic Process Integrator Studio

Client application that is used at design time to define workflows and at run time to monitor running workflows.

WebLogic Process Integrator Process Engine

Run-time controller and workflow engine that executes and manages workflows and tracks workflow instances.

WebLogic Process Integrator Database

Database in which workflow templates are stored.

This database can reside locally on the c-enabler node, or it can reside on a different node that is network accessible to the c-enabler. The database can be deployed so that it is accessible to a single c-enabler only, to multiple c-enablers within the same trading partner organization, or to multiple c-enablers across trading partners in different organizations.

WebLogic Process Integrator Worklist

Application that is used to view and perform tasks that are currently assigned to a user or to roles to which the user belongs, such as reassigning tasks to other users, marking tasks as done, unmarking tasks done, viewing a workflow status, manually starting a workflow, and so on.

For an introduction to these WebLogic Process Integrator components, see WebLogic Process Integrator Overview in the BEA WebLogic Process Integrator Studio User Guide.

Key Concepts

This section describes key concepts that you need to understand before using WebLogic Process Integrator workflows in WebLogic Collaborate applications.

Workflows, Workflow Templates, and Workflow Template Definitions

This section describes the following key WebLogic Process Integrator concepts:

For detailed information about these concepts, see WebLogic Process Integrator Overview in the BEA WebLogic Process Integrator Studio User Guide.

Conversations, Conversation Definitions, and Business Messages

This section defines the following key WebLogic Collaborate concepts:

For detailed information about these concepts, see Overview in BEA WebLogic CollaborateGetting Started.

Initiators and Participants

A conversation involves an initiator who starts the conversation and participants who participate in the conversation once it has started. Each perspective requires a different kind of workflow.

Table 2-2 Types of Workflows

Workflow Type

Description

Conversation initiator workflow

Defined to have conversation properties and a non-Business Message start property. This type of workflow initiates and terminates the conversation.

Conversation participant workflow

Defined to have conversation properties and a Business Message start property. This type of workflow can join and exit the conversation but cannot initiate or terminate it.

In the context of a business process, these two types of workflows are interlocking. For example, suppose a buyer wanted to obtain bids from various sellers. This business process could be described as follows.

Figure 2-2 Sample Business Process with Two Workflows

  1. In WebLogic Process Integrator Studio, the buyer (the initiating trading partner) starts a workflow named GetBids (the conversation initiator workflow). The GetBids workflow constructs and sends a business message (containing a bid request in the form of an XML document) by way of the c-hub to qualified sellers and awaits a reply.

    Note: The GetBids workflow is defined with conversation properties and a Manual start property. It is started programmatically by using a Java application.

  2. Each qualified seller (a participant trading partner) receives the business message, which triggers the start of an instance of a workflow named SubmitBid (the conversation participant workflow) on each seller's c-enabler node.

    The SubmitBid workflow processes the incoming bid request, determines whether to submit a bid or not and, if so, constructs and sends a business message (containing a bid reply in the form of an XML document), and awaits the results of the bid selection.

    Note: The SubmitBid workflow is defined with conversation properties and a Message Start property.

  3. On the buyer side, the GetBids workflow receives bid replies from all qualified sellers, determines which seller to award the bid, and then notifies all sellers of the results by:

  4. On the seller side, the SubmitBid workflow receives and processes the results of the bid.

  5. On the buyer side, the GetBids workflow receives and processes the bid confirmation from the seller and then terminates the conversation.

Sent and Received Business Messages

When trading partners exchange business messages, initiator and participant workflows both typically send and receive business messages.

It is important to keep in mind which parts of the workflow send business messages and which parts receive them. For example, a buyer might submit a bid request (a business message) to a seller. In this case, the buyer workflow is sending the business message and the seller workflow is receiving it. When the seller replies to the request with a bid (another business message), then the roles are reversed: the seller workflow is the sender and the buyer is the recipient workflow.

The design and programming tasks differ for sending and receiving business messages. However, in both cases, you must define certain properties in the workflow template definition and write application code (that implements the com.bea.b2b.wlpi.MessageManipulator interface) to manipulate the business message.

For more information about working with business messages, see Working with Business Messages.

Run-Time Prerequisites

Before exchanging messages at run time, the following prerequisites must be met:

Summary of Workflow Integration Tasks

Using WebLogic Process Integrator workflows to exchange business messages in WebLogic Collaborate requires a combination of administrative, design, and programming tasks.

Administrative Tasks

Integrating WebLogic Process Integrator workflows requires the following administrative tasks:

  1. Install WebLogic Collaborate, and configure WebLogic Process Integrator according to the instructions in Setting Up the WebLogic Process Integrator Environment in BEA WebLogic Collaborate Getting Started.

  2. For c-enabler nodes, specify the workflow c-enabler session names you want to use in the c-enabler XML configuration file. For more information, see Configuring C-Enablers in the BEA WebLogic Collaborate C-Enabler Administration Guide.

  3. Using the C-Hub Administration Console, create and configure the necessary entities in the c-hub repository, including c-spaces, trading partners, conversation definitions, document definitions, and so on. For more information, see the BEA WebLogic Collaborate C-Hub Administration Guide.

    Note: Every WebLogic Process Integrator workflow template definition requires a conversation definition.

  4. Using WebLogic Process Integrator Studio, specify the organizations, users, and roles in the WebLogic Process Integrator database, as described in Administering Data within WebLogic Process Integrator in the BEA WebLogic Process Integrator Studio User Guide.

Design Tasks

Integrating WebLogic Process Integrator workflows requires the following design tasks that you perform in WebLogic Process Integrator Studio:

  1. Create and design workflows that automate business processes.

    You can create workflows from scratch, as described in Defining and Maintaining Workflows in the BEA WebLogic Process Integrator Studio User Guide.

    Alternatively, you can import workflows created in other versions of WebLogic Process Integrator, as described in Using Workflow Templates Created in Other WebLogic Process Integrator Versions.

    In addition to defining the standard workflow properties, you must also define properties that link the workflow to the WebLogic Collaborate messaging system. The remaining tasks in this sequence apply to integrating workflows into WebLogic Collaborate.

  2. For each workflow template definition, specify conversation properties as follows:

  3. For each workflow template definition, define start actions depending on the type of workflow.

  4. For each workflow template definition, define how the workflow will end.

  5. For any input or output variables used in the workflow, define them in the workflow template definition, as described in Defining WebLogic Process Integrator Variables for Workflows.

  6. For each workflow template definition, define how business messages are processed and exchanged.

For comprehensive information about workflow design tasks, see Designing Workflows for Exchanging Business Messages.

Note: You can run WebLogic Process Integrator workflows in the WebLogic Collaborate environment even if they are not integrated with WebLogic Collaborate features. For example, you can run workflows created in WebLogic Process Integrator version 1.2 (shipped separately from WebLogic Collaborate) without specifically adapting them to integrate with WebLogic Collaborate.

Programming Tasks

Programming tasks depend on the specific needs of each application that makes use of a workflow. The following tasks are required:

 


Designing Workflows for Exchanging Business Messages

To use workflows to exchange business messages in WebLogic Collaborate, design workflow template definitions by using WebLogic Process Integrator Studio. In addition to the standard properties described in Defining and Maintaining Workflows in the BEA WebLogic Process Integrator Studio User Guide, you must define additional workflow properties, not described in that document, that allows the workflow to be used in the WebLogic Collaborate environment.

For example, you link a workflow template definition to a particular role in a conversation definition in the c-hub repository. You also define some additional attributes, including the message delivery Quality of Service, message token handling, and conversation termination.

The following sections describe how to design workflows to exchange business messages in the WebLogic Collaborate environment:

Using Workflow Templates Created in Other WebLogic Process Integrator Versions

The version of WebLogic Process Integrator that ships with WebLogic Collaborate is designed to work seamlessly within the WebLogic Collaborate environment. If you have workflows that were designed in other versions of WebLogic Process Integrator, you can use still these workflows in WebLogic Collaborate, but you must complete the following additional tasks to adapt them for use in WebLogic Collaborate:

  1. Export the associated workflow template definition from the earlier version of WebLogic Process Integrator, as described in Exporting Workflow Template Definitions.

  2. Import the workflow template definition that you previously exported into the WebLogic Process Integrator that ships with WebLogic Collaborate, as described in Importing Workflow Template Definitions.

  3. Modify the workflow template design to work with WebLogic Collaborate, as described in the section that begins with Designing Workflows for Exchanging Business Messages.

Note: Standalone versions of WebLogic Process Integrator cannot use workflows that were created or modified using the version of WebLogic Process Integrator Studio that ships with WebLogic Collaborate.

Exporting Workflow Template Definitions

To export a workflow template definition from a WebLogic Process Integrator version that shipped separately from WebLogic Collaborate:

  1. In the folder tree, right-click the workflow template definition you want to export.

  2. Choose Export from the pop-up menu.

  3. In the Save dialog box, select the location (drive and directory) where you want to save the exported workflow template definition.

  4. Specify the file name of the exported workflow template definition.

  5. Click Save.

Importing Workflow Template Definitions

To import a previously exported workflow template definition (see Exporting Workflow Template Definitions) into the version of WebLogic Process Integrator that ships with WebLogic Collaborate:

  1. In the WebLogic Process Integrator folder tree, right-click the workflow template into which you will import the workflow template definition.

  2. From the pop-up menu, choose Import Template Definition.

  3. In the Save dialog box, select the current location (drive and directory) of the exported workflow template definition file that you want to import.

  4. Click Save.

  5. After the file is read, an import confirmation dialog box appears. Click Yes to confirm importing the workflow template definition.

  6. Imported workflow template definitions are always marked "inactive." Before an imported workflow template definition can be instantiated, you must change its definition to "active" in the Template Definition dialog box. For more information, see Defining and Maintaining Workflows in the BEA WebLogic Process Integrator Studio User Guide.

Defining Conversation Properties

Before you use a WebLogic Process Integrator workflow to exchange business messages in WebLogic Collaborate, you define certain conversation properties that are specific to the WebLogic Collaborate environment. For detailed information about defining workflow templates, see Defining and Maintaining Workflows in the BEA WebLogic Process Integrator Studio User Guide.

Opening Workflow Template Definitions

To define a workflow template definition in WebLogic Process Integrator Studio:

  1. Do one of the following:

  2. Right-click the template definition and choose Properties from the pop-up menu to display the Template Definition dialog box.

    Figure 2-3 Template Definition Dialog Box

  3. Complete the fields in the Template Definition dialog box, as described in Defining and Maintaining Workflows in the BEA WebLogic Process Integrator Studio User Guide.

  4. To define conversation properties, click Conversations.

  5. Click OK to save your changes.

Linking Workflows to Conversations

Before you use a WebLogic Process Integrator workflow to exchange business messages in WebLogic Collaborate, you first link the workflow template definition in WebLogic Process Integrator with a particular conversation type (a conversation name, version, and WebLogic Collaborate role) in the WebLogic Collaborate c-hub repository.

To link a workflow template definition with conversation type:

  1. Open the Template Definition dialog box, as described in Opening Workflow Template Definitions.

  2. In the Template Definition dialog box, click the Conversations button to display the Conversation Properties dialog box.

    Figure 2-4 Conversation Properties Dialog Box

  3. Complete the following fields in the Conversation Properties dialog box.

    Table 2-3 Fields in the Conversation Properties Dialog Box

    Field

    Description

    Name

    Name of the WebLogic Collaborate conversation definition in the c-hub repository to link with this workflow template definition.

    Version

    Version number of the conversation definition in the c-hub repository to link with this workflow template definition.

    Role

    Role in the conversation definition to link with this workflow template definition. In order for a trading partner to receive messages in this conversation, it must be registered in this role in the conversation at run time.

    Quality of Service

    Message delivery quality of service, as described in Defining the Quality of Service for Message Delivery at the Template Level.

    Session

    C-enabler session name(s) for which this workflow template should be used, as described in Linking C-Enabler Session Names to a Workflow Template Definition.

  4. Click OK to save your changes.

Defining the Quality of Service for Message Delivery at the Template Level

The Quality of Service (QoS) is a set of attributes that are defined for reliable business message publishing. In WebLogic Process Integrator, you can define the QoS at the following levels:

To specify the Quality of Service at the workflow template definition level:

  1. Open the Conversation Properties dialog box for a workflow template definition, as described in Linking Workflows to Conversations.

  2. In the Conversation Properties dialog box, click the Quality of Service button to display the Quality of Service Settings dialog box.

    Figure 2-5 Quality of Service Settings Dialog Box

  3. Complete the following fields in the Quality of Service Settings dialog box.

    Table 2-4 Fields in the Quality of Service Dialog Box

    Field

    Description

    Confirm Message Delivery

    Degree to which message delivery confirmation is required: up to the c-hub (the default), up to the router in the c-hub, or to all destinations. Your selection determines which options are available in the Message Token Assignments dialog box, as described in Assigning Message Token Information to WebLogic Process Integrator Variables.

    Delivery confirmation is required when a message reaches the c-hub (default). Select this option to provide basic delivery confirmation with maximum run-time performance.

    Delivery confirmation is required when a message reaches the router in the c-hub. This option provides the list of trading partners selected by the c-hub router to receive the message.

    Delivery confirmation is required from all destinations. Select this option to provide the maximum delivery confirmation details. May affect run-time performance.

    Retry Attempts for Send

    Maximum number of retries for sending a message (default is 0). The WebLogic Process Integrator Process Engine will repeatedly attempt to send a message until it either successfully sends the message or it exceeds the maximum number of retries. A WebLogic Process Integrator exception will be thrown if the maximum retries are exceeded.

    Timeout for Send

    Timeout value for sending a message (default is 0, which means no timeout). The WebLogic Process Integrator Process Engine will wait until either a delivery confirmation is received or the timeout period has been exceeded.

    Correlation ID

    Message identification string that can be used to correlate the message with other business messages in the application (default is none). For example, a trading partner might want to specify a correlation ID in a request so that replies to that request can be matched to the original request. The WLC messaging system includes this property with the message.

    Durability Options

    Durability options for messaging: Persistence or Non-persistence (default). Overrides the default setting (if specified) for the associated conversation definition in the c-hub repository.

    Non-Persistence

    Messages are not to be saved in a persistent state. This option improves run-time performance but will reduce the likelihood of recovery from a system failure.

    Persistence

    Messages are to be saved in a persistent state. This option increases the likelihood of recovery from a system failure but requires additional processing that might affect run-time performance.

    Notes

    Optional descriptive text.

  4. Click OK to save your settings.

Linking C-Enabler Session Names to a Workflow Template Definition

You can associate a workflow template definition with one or more workflow c-enabler session names. At a minimum, you must link at least one c-enabler session name. The WebLogic Process Integrator Studio allows you to add, update, and delete linked session names.

A workflow template definition can have more than one defined session name. This allows the same workflow template definition (different instances) to be used by different c-enablers in the same conversation. For example, a workflow template definition could be defined with three different session names (such as sessionA, sessionB, and sessionC). Each trading partner in the conversation can then use the appropriate session when providing their own implementation (manipulate message) to process the request.

Session names are defined in the c-enabler XML configuration file. Each session name refers to one session entry in a c-enabler configuration file (which is known only at run time). Each session entry in the c-enabler XML configuration file refers to a specific c-hub, c-space, and trading partner.

Adding Sessions

To add a session:

  1. In the Conversation Properties dialog box, click Add to display the Define Session dialog box.

    Figure 2-6 Define Session dialog box

  2. Enter a unique session name.

  3. Click OK to save your changes.

Updating Sessions

To update a session:

  1. In the Conversation Properties dialog box, select the session you want to update and then click Update to display the Define Session dialog box.

    Figure 2-7 Define Session dialog box

  2. Edit the session name. It must be a unique session name.

  3. Click OK to save your changes.

Deleting Sessions

To delete a session:

  1. In the Conversation Properties dialog box, select the session you want to delete and then click Delete to display the Delete Session dialog box.

    Figure 2-8 Delete Session dialog box

  2. Click Yes.

Defining Start Actions

You define a start action based on the type of workflow and according to the following rules:

Defining the Start for a Conversation Initiator Workflow

A conversation initiator workflow is started programmatically and must therefore have a Manual start property. For more information, see Developing Applications That Start Conversation Initiator Workflows.

To define the Manual start property for a conversation initiator workflow:

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

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

    Figure 2-9 Start Properties Dialog Box: Manual Start

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

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

    Otherwise, select any other option except Business Message as appropriate. For more information about these options, see Working with Workflow Components in the BEA WebLogic Process Integrator Studio User Guide.

  5. Click OK.

Defining the Start for a Conversation Participant Workflow

A conversation participant workflow is started when it receives an initial business message from a conversation initiator workflow. 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 the BEA WebLogic Process Integrator Studio User Guide.

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

    Figure 2-10 Start Properties Dialog Box: Business Message Start

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

  4. Select Business Message.

  5. Select the Business Protocol.

  6. Specify the target variable, as described in Working with Workflow Components in the BEA WebLogic Process Integrator Studio User Guide.

  7. Specify the sender filter variable, as described in Working with Workflow Components in the BEA WebLogic Process Integrator Studio User Guide.

  8. Click OK.

Defining Conversation Termination

A conversation is terminated when the conversation initiator workflow reaches a done state. Conversation participant workflows can end their participation in a conversation before the conversation is terminated.

Defining the Termination of Conversation Initiator Workflows

For a conversation initiator workflow, you define the conversation termination property (terminate with success or failure) for any done node in the workflow. Once a done node is reached in the workflow, the running instance of the workflow is marked done, regardless of whether the active workflow has reach all the done nodes. A conversation initiator workflow can terminate a conversation, but other participants in the conversation cannot.

To define the termination for a conversation initiator workflow:

  1. Add or view a done shape, as described in Working with Workflow Components in the BEA WebLogic Process Integrator Studio User Guide.

  2. Double-click the done shape or right-click it in the folder tree and choose Properties to display the Done Properties dialog box.

    Figure 2-11 Done Properties Dialog Box

  3. Select a conversation termination option in the Done Properties dialog box.

    Table 2-5 Conversation Termination Options in the Done Properties Dialog Box

    Graphic

    Field

    Description


    Success

    The conversation should be terminated with a SUCCESS result (default). The conversation is terminated after the actions for this state are done.

    The SUCCESS result indicates that the workflow instance completed successfully. The participants of the conversation will be notified (if possible) that the conversation is being terminated.


    Failure

    The conversation should be terminated with a FAILURE result. The conversation is terminated after the actions for this state are done.

    The FAILURE result indicates that the workflow instance encountered conversation-specific or application-specific errors. The participants of the conversation are notified (if possible) that the conversation is being terminated.

Defining the End of Conversation Participant Workflows

A conversation participant workflow has defined conversation properties, a Business Message start property, and (optionally) a Conversation Terminate event. The Conversation Terminate event is used in a participant workflow to wait for a conversation termination signal from the conversation initiator. It allows a participant workflow to perform additional processing (such as housekeeping operations) based on the status of the conversation termination.

Note: The use of this event is optional. A workflow that does not wait for this event can leave the conversation by simply ending the workflow (a Done node).

A workflow event shape represents a notification node. The workflow waits for a conversation terminate to trigger the event. Upon that trigger, actions defined within the event can be executed and/or workflow variables can be set.

To add a Conversation Terminate event to a conversation participant workflow:

  1. Display or add any task as described in Working with Workflow Components in the BEA WebLogic Process Integrator Studio User Guide.

  2. Double-click the event shape or right-click it in the folder tree and choose the Properties command to display the Event Properties dialog box.

    Figure 2-12 Event Properties Dialog Box

  3. Select Conversation Terminate Event.

  4. Select a WebLogic Process Integrator Boolean variable to store the terminate status, which will be set to one of the values in the following table.

    Table 2-6 Terminate Status Options in the Event Properties Dialog Box

    Option

    Description

    True

    Indicates that the conversation was terminated with a SUCCESS value.

    False

    Indicates that the initiator has terminated the conversation with a FAILURE value.

    Note: You must explicitly create this Boolean variable before selecting it in this dialog box. For more information, see Defining WebLogic Process Integrator Variables for Business Messages.

  5. Click OK to save your changes.

WebLogic Process Integrator assigns the conversation terminate status value to a WebLogic Process Integrator Boolean variable, which can be accessed by the workflow or passed to a business operation. The developer of the workflow should take appropriate actions based on this value.

Defining WebLogic Process Integrator Variables for Workflows

A WebLogic Process Integrator variable is typically used to store application-specific information required by the workflow at run time. Variables are created and assigned values largely to "control" the logical path through a workflow instance; the same workflow template definition is instantiated multiple times and can be traversed in different ways if the flow contains decision nodes, which evaluate workflow variable values and branch to either the next True or next False within the workflow, as appropriate.

You must define WebLogic Process Integrator variables for a workflow template definition that contains processes that require variables during run time. During workflow execution, you can access a WebLogic Process Integrator variable in the following ways:

Associations Between WebLogic Process Integrator Variables and Java Data Types

If you access a WebLogic Process Integrator variable within a business operation, you need to know how WebLogic Process Integrator variable types correspond to Java data types. The following table shows how they are related.

Table 2-7 WebLogic Process Integrator Variables and Java Data Types

WLPI Variable Type

Java Data Type

String

java.lang.String

Integer

Java.lang.Integer

Long

Java.lang.Long

Double

java.lang.Double

Date

java.util.Date

Boolean

java.lang.Boolean

Complex Object

java.lang.Object

(must implement Serializable)

XML

org.w3c.dom.Node

Rules for Defining WebLogic Process Integrator Variables

When defining WebLogic Process Integrator variables, comply with the following rules:

Defining Input Variables

Before a WebLogic Collaborate application can set an input variable, you must define it in WebLogic Process Integrator Studio.

To define an input variable:

  1. Do one of the following:

  2. Complete the fields in the following Variable Properties dialog box.

    Table 2-8 Fields in the Variable Properties Dialog Box

    Field

    Description

    Name

    Meaningful name for the variable, such as ItemNumber.

    Type

    Variable type: Boolean, Date, Double, Entity EJB, Integer, Java Object, Session EJB, String, Long, or XML.

    Parameter

    Input or Output. For Input, choose whether the parameter is a mandatory one.

    Notes

    Optional descriptive text.

  3. Select Input.

  4. Click OK.

In the preceding example, the variable named requestString0 is declared as an input variable. It is also declared as mandatory, which means that the workflow instance will start only if the WebLogic Collaborate application explicitly sets its value before attempting to start the workflow instance. For more information, see Developing Applications That Start Conversation Initiator Workflows.

Defining Output Variables

Variables that must be retrieved after the workflow completes must be declared as output variables. Otherwise, their value will not be preserved.

To define an output variable:

  1. Do one of the following:

  2. Complete the fields in the Variable Properties dialog box, as described in Working with Workflow Components in the BEA WebLogic Process Integrator Studio User Guide.

  3. Select Output.

  4. Click OK.

 


Working with Business Messages

You use WebLogic Process Integrator in conjunction with WebLogic Collaborate to exchange business messages between trading partners. The following sections describe how to work with business messages exchanged by using workflows:

About Business Messages

A business message is the basic unit of communication exchanged between trading partners in a conversation. A business message is a multi-part MIME message that consists of:

You can access the contents of a business message programmatically using XOCP messaging objects, as described in Step 1: Create the Business Message and Receiving an XOCP Business Message.

Summary of Prerequisite Tasks for Exchanging Business Messages

You must perform the following tasks before you can send and receive business messages. Subsequent sections describe these tasks in detail.

Defining Variables and Manipulating Business Messages

The following sections describe procedures you perform in regard to both sent and received messages:

Defining WebLogic Process Integrator Variables for Business Messages

At run time, a business message is stored in a WebLogic Process Integrator variable (of type Java Object) when it is ready to be sent or when it has been received. When a business message is ready to be sent, the application code associated with the Manipulate Business Message action constructs the business message and returns it in this variable to the workflow instance. When a business message has been received, the application code associated with the Manipulate Business Message action obtains this variable from the workflow instance and uses it to process the incoming business message.

Note: In WebLogic Collaborate, XOCP business messages are not stored in WebLogic Process Integrator variables of type XML Document.

In WebLogic Process Integrator Studio, you must define the Java Object variables used to store business messages before you define any actions that refer to them, as described in Defining Manipulate Business Message Actions.

For each workflow template definition, you must define a separate variable for each business message that the workflow sends or receives. For example, if a workflow sends a request and receives a reply, you must define variables for both in its workflow template definition.

To define a variable for a business document in WebLogic Process Integrator Studio:

  1. In the folder tree, right-click Variables under the appropriate workflow template definition and choose New Variable to display the Variable Properties dialog box.

    Figure 2-15 Variable Properties Dialog Box

  2. Specify a unique name for this variable.

  3. Select the Java Object variable type.

  4. Click OK.

Defining Manipulate Business Message Actions

At run time, the Manipulate Business Message action is invoked to manipulate a business message. If the workflow is sending a business message (such as request), the Manipulate Business Message action runs the associated application code to create the business message and save it in an output variable that is sent subsequently in a Send Business Message action. If the workflow is receiving a business message (such as a reply), the Manipulate Business Message action captures the incoming business message in an input variable and passes it onto the associated application code for processing.

The Manipulate Business Message action can be associated with any of the following nodes: task, decision, event, and start. You must explicitly add the Manipulate Business Message action to the workflow template definition.

Adding a Manipulate Business Message Action

To define the Manipulate Business Message action for a workflow in WebLogic Process Integrator Studio:

  1. In any dialog box where you can specify an action (such as the Task, Decision, Event, or Start Properties dialog box), click Add to display the Add Action dialog box.

    Figure 2-16 Add Action Dialog Box

  2. Click the Integration Actions folder to expand it.

    Figure 2-17 Add Action Dialog Box With Integration Actions

  3. Select Manipulate Business Message.

  4. Click OK to display the Manipulate Business Message dialog box.

    Figure 2-18 Manipulate Business Message Dialog Box

  5. Complete the following fields in the Manipulate Business Message dialog box.

    Table 2-9 Fields in the Manipulate Business Message Dialog Box

    Field

    Description

    Class Name

    Required. Name of a Java class that implements the com.bea.b2b.wlpi.MessageManipulator interface. For more information, see Writing Business Operations to Manipulate Business Messages.

    Input variable

    Name of a WebLogic Process Integrator variable that contains an existing business message, such as a message that has been received through a Receive Business Message action.

    The contents of this variable will be passed as the in parameter to the manipulate operation in the specified Java class that implements the com.bea.b2b.wlpi.MessageManipulator interface. If no variable name is specified, the value of the in parameter will be null.

    The specified variable must correspond to an existing WebLogic Process Integrator variable of type Java Object. For more information, see Defining WebLogic Process Integrator Variables for Business Messages.

    Output variable

    Name of a WebLogic Process Integrator variable that will contain the business message returned by the manipulate operation in the specified Java class that implements the com.bea.b2b.wlpi.MessageManipulator interface.

    The specified variable must correspond to an existing WebLogic Process Integrator variable of type Java Object. For more information, see Defining WebLogic Process Integrator Variables for Business Messages. If no variable name is specified, then the return value of the manipulate operation will be ignored.

    Notes

    Optional descriptive text.

    When specifying input or output variables, follow these guidelines:

  6. Click OK to save your changes.

Example of a Manipulate Business Message Action

For example, suppose you specify the following settings in the Manipulate Business Message dialog box.

Table 2-10 Sample Settings in the Manipulate Business Message Dialog Box

Field

Description

Class name

examples.wlpiverifier.ProcessRequest

Input variable

requestMsg

Output variable

replyMsg

At run time, when the WebLogic Process Integrator Process Engine executes the action with the specified settings, the following events occur:

  1. An object of class examples.wlpiverifier.ProcessRequest is created using reflection and the default constructor.

  2. The value of the in parameter (requestMsg) is retrieved.

  3. The manipulate operation is invoked on the object.

  4. The return value of the manipulate operation is stored in the WebLogic Process Integrator output variable (replyMsg).

Writing Business Operations to Manipulate Business Messages

You write business operations that use WebLogic Process Integrator variables and Java code to manipulate business messages that are exchanged between trading partners. The Manipulate Business Message action invokes a special WebLogic Collaborate business operation, a message manipulator, to create a business message to send or to process a business message that has been received. A message manipulator is a Java class that implements the com.bea.b2b.wlpi.MessageManipulator interface.

For more information about defining the message manipulator class and input and output variables for the Manipulate Business Message action, see Defining Manipulate Business Message Actions. For more information about the com.bea.b2b.wlpi.MessageManipulator interface, see the WebLogic Collaborate Javadoc.

Supported Operations

Message manipulators support the following operations for processing business messages:

MessageManipulator Interface

To process business messages that are exchanged between roles in a conversation, workflow applications use Java classes that implement the com.bea.b2b.wlpi.MessageManipulator interface. This interface contains a single operation, manipulate, with the following signature:

XOCPMessage manipulate(WorkflowInstance instance, XOCPMessage in) throws WLPIException;

When calling the manipulate operation, a workflow specifies the following parameters.

Table 2-11 Parameters in the Manipulate Operation

Parameter

Description

instance

Current workflow instance, which can be used to get or set variables. For more information, see Defining WebLogic Process Integrator Variables for Business Messages.

in

XOCP message stored in the WebLogic Process Integrator variable specified as an input variable in the associated Manipulate Business Message action. If no input variable was specified in the Manipulate Business Message action or if the variable is empty, then null is passed.

The manipulate operation returns an XOCP message generated by the message manipulator. At run time, this XOCP message is stored in the output variable specified in the associated WebLogic Process Integrator Manipulate Business Message action. If this output variable was not specified, then the return value is ignored.

Note: Classes that implement the message manipulator interface must have a public default constructor (a constructor without arguments). The Process Engine uses Java reflection to create objects of that class and therefore invokes the default constructor.

Creating and Defining Messages to Send

The following sections describe how to prepare messages to be sent:

Steps for Creating Business Messages

The PrepareQuery class in the WebLogic Process Integrator Verifier program is an example of a message manipulator that constructs a business message before it is sent. It is called by the Manipulate Business Message action that occurs in the workflow. It returns a reply message (replyMsg variable) that is passed back to the workflow as the business message to send.

Step 1: Import the Necessary Packages

The following listing shows the packages that the PrepareQuery class imports, which includes the XOCP messaging objects that are used to create the XOCP message.

Listing 2-1 Importing the Necessary Packages


package examples.wlpiverifier;

import java.io.*;

import org.apache.xerces.dom.*;
import org.w3c.dom.*;

import com.bea.eci.logging.*;
import com.bea.b2b.wlpi.MessageManipulator;
import com.bea.b2b.wlpi.WorkflowInstance;
import com.bea.b2b.wlpi.WLPIException;

import com.bea.b2b.protocol.conversation.ConversationType;
import com.bea.b2b.enabler.*;
import com.bea.b2b.enabler.xocp.*;
import com.bea.b2b.protocol.messaging.*;
import com.bea.b2b.protocol.xocp.conversation.local.*;
import com.bea.b2b.protocol.xocp.messaging.*;


Step 2: Implement the MessageManipulator Interface

The following listing shows the PrepareQuery class declaration that implements the MessageManipulator interface.

Listing 2-2 Implementing the MessageManipulator Interface


public class PrepareQuery implements MessageManipulator{
...
}


Step 3: Call the Manipulate Method

The code in the following listing calls the manipulate method, which retrieves the current workflow instance object as well as the incoming business message.

Listing 2-3 Calling the manipulate Method


  public XOCPMessage manipulate(WorkflowInstance instance,
XOCPMessage in)
throws WLPIException{


Step 4: Get the Input Variables from the Current Workflow Instance

The code in the following listing gets the input variables associated with the current workflow instance by calling the getVariable method on the workflow instance.

Note: The WlpiVerifierConstants class contains constant values.

Listing 2-4 Getting the Input Variables


    int current = ((Integer)instance.getVariable(WlpiVerifierConstants.CURRENT)).intValue();

String req = (String)instance.getVariable(WlpiVerifierConstants.REQUESTSTR + current);
boolean last;
if (current < 4){
try{
String v = (String)instance.getVariable(WlpiVerifierConstants.REQUESTSTR + (current + 1));
if (v == null || v.length() == 0)
last = true;
else
last = false;
}catch (WLPIException e){
last = true;
}
}else
last = true;

if (last)
instance.setVariable("last", new Integer(1));


The code in the following listing creates the request message. For more information about creating XOCP business messages, see Step 1: Create the Business Message.

Listing 2-5 Creating the Request Message


    XOCPMessage xocpmsg = null;
try{
DOMImplementationImpl domi = new DOMImplementationImpl();

// "request" - (param1) The qualified name of the document type to be created.
// "request" - The document type public identifier.
// "upper-request.dtd" - The document type system identifier
DocumentType dType = domi.createDocumentType("request",
"request", "upper-request.dtd");

org.w3c.dom.Document rq = new DocumentImpl(dType);
Element root = rq.createElement("request");
rq.appendChild(root);
Text t = rq.createTextNode(req);
root.appendChild(t);
root.setAttribute("last", last ? "true" : "false");

xocpmsg = new XOCPMessage("");
xocpmsg.addPayloadPart(new BusinessDocument(rq));

}catch(Exception e){
e.printStackTrace();
throw new WLPIException("PrepareQuery raised exception:" + e);
}


Step 5: Return the Request Message

The code in the following listing returns the request message in the variable xocpmsg (of type XOCPMessage) The return value is then assigned to an output variable (of type Java Object) in the workflow in preparation for sending the business message.

Listing 2-6 Returning the Request Message


    return xocpmsg;


Defining Send Business Message Actions

After you create a business message in WebLogic Process Integrator using a Manipulate Business Message action and a message manipulator, you send the business message using the Send Business Message action.

To define a Send Business Message action:

  1. In any dialog box where you can specify an action (such as the Task, Decision, Event, or Start Properties dialog box), click Add to display the Add Action dialog box.

    Figure 2-19 Add Action Dialog Box

  2. Click the Integration Actions folder to expand it.

    Figure 2-20 Add Action Dialog Box With Integration Actions

  3. Select Send Business Message, and then click OK to display the Send Business Message dialog box.

    Figure 2-21 Send Business Message Dialog Box

  4. Complete the following fields in the Send Business Message dialog box.

    Table 2-12 Fields in the Send Business Message Dialog Box

    Field

    Description

    Source Variable

    Name of a WebLogic Process Integrator Java Object variable that contains an XOCPMessage, probably created by an earlier call to a message manipulator. Required field. For more information, see Defining WebLogic Process Integrator Variables for Business Messages.

    Router Expression Contains

    Contents of the Router Expression field: a trading partner name or an XPath expression. Router expressions might be overridden by router expressions specified in the c-hub repository. For more information about routers, see Routing and Filtering XOCP Business Messages in the BEA WebLogic Collaborate C-Hub Administration Guide.

    The Router Expression field contains a single trading partner name.

    The Router Expression field contains an XPath expression.

    The Router Expression field contains a WebLogic Process Integrator variable (of type String) with the contents of the Xpath expression. The variable is sele