WSO2 Business Process Server v3.0.1 Documentation

##### Overview

- Home
- Release Note
- WS-BPEL Compliance
- License

##### Downloads

- Releases

##### Installation Guide

- Installing WSO2 BPS

##### Quick Start Guide

- Modeling the process
- Deploying the process
- Testing the process

##### User Guide

- Deploying BPEL Processes
- Deploying Human Tasks
- Managing BPEL processes
- Managing BPEL process instances
- QoS for BPEL processes
- Securing BPEL processes
- Invoking secured partner services
- Versioning
- Management API

##### Human Task Guide

- Human Tasks Quick Start Guide
- Deploying HumanTasks
- Managing Tasks
- Developing a Human Task Artifact
- Human Task Management and Configuration
- Human Task Concepts

##### Administrator Guide

- External data sources Configuration
- Registry Configuration
- Events
- Unified Endpoints
- BPEL Extensions
- Transaction Factory Configuration
- Message Exchange Interceptors
- OpenJPA specific properties
- JMS Transport Configuration
- Process Instance Cleanup Tasks
- Process Hydration and Dehydration
- Enabling Peer-to-Peer(P2P) Communication
- Setting up a BPS Cluster

##### Best Practices

- Process Deployment Best Practices

##### Concepts

- Process Versioning
- Process instance events
- Partner links

##### WS-BPEL Extensions

- Activity Failure and Recovery
- Extension Activities and Extensible Assign Operations
- XPath Extensions
- Iterable ForEach
- Flexible Assigns
- BPEL4People Extension

##### Samples

- HelloWorld
- If-Else
- ForEach
- While
- Repeat Until
- Flow and Links
- Pick
- Synchronous and Asynchronous Service Invocations
- Fault Handling
- Split
- XslTransform
- Compensation Handler
- Event Handler

##### Resources

- FAQ
- External Articles
- Library
- Source Code

##### Community

- Forum
- Mailing Lists

##### Project Information

- Issue Tracking

# External Variables

- Declaring External Variables in the Process Definition
- Incomplete Keys
- JDBC Mapping

## Declaring External Variables in the Process Definition

NOTE: External variables are only available in WSO2 Business Process Server 1.1.x

Syntax:

    <scope>
       <variables xmlns:xvar=" http://ode.apache.org/externalVariables">
         <variable name="ext-var-name" element="ext-var-type" xvar:id="ext-var-id">
            <xvar:key-map key="key-id">*
                <expression>key-expression</expression>
            </xvar:key-map>
         </variable>
        </variables>
    </scope>

External variables are declared in the <variables> section of the <scope> element, just like normal variables. However, unlike regular variables, external variables must specify the additional xvar:id attribute. This attribute identifies the variable as an external variable and links the external variable's declaration to the external variable's configuration in the deployment descriptor.

In addition to this attribute, an external variable may also define a set of key mappings by nesting xvar:key-map elements within the declaration. The key mappings are a collection of name-expression pairs that is used to create a composite key (identity) for the external variable. This composite key is used to retrieve the correct "instance" of the variable from the underlying storage. The key mappings are BPEL expressions ( i.e. XPath expressions) that are evaluated once, at the time that the scope is instantiated. Therefore, the "identity" of an external variable is determined during scope creation, and cannot be changed by the process (for qualifications see Incomplete Keys below).

Finally, any external variables must be of an "element" type, with a schema conforming to the requirements of the underlying storage mechanism.

Consider the following example:

    .
    .
    .
    <scope>
    <variables>
    <variable name="customer" element="myns:CustomerElement" xvar:id="customer1" >
       <xvar:key-map key="customer-id">
           <expression>$order/customerid</expression>
       </xvar:key-map>
    </variables>
    </scope>
    .
    .
    .

In the above, the "customer" variable is an external variable. The key for the external variable is derived from the value of the customerid element in the "order" variable. Note that the "order" variable must be declared in a scope above the scope declaring the "customer" external variable, otherwise it would not be possible to resolve the identify of the "customer" variable. In this scenario, the external variable can be "read" even if it was never assigned to in the process.

## Incomplete Keys

It is not required that the full identity of the external variable be resolved at scope creation. For example, an external variable may correspond to a database row where the identity is generated by the database during an insert operation. In such a scenario the key mapping can be omitted, and the identity of the external variable will be unknown until the variable is assigned to. Any attempt to access the variable before the first assignment will result in an uninitialized variable fault. In general it is possible to specify external variables where some portions of the identity are determined using the key mappings and some using some other (implementation-specific) mechanism. In any case, if when the variable is read, the key is incomplete an initialised variable fault will result.

## JDBC Mapping

External Variables - JDBC Mapping