# Creating Variables

There are two ways of creating variables for your business process. Variables can be created in the Data Palette by selecting Add —> Variable or they can be created in the node builder when you are configuring the Send Data or Receive Data section of a Client Request, Client Request with Return (Start Node only), Client Response, Subscription (Start Node only), Control Send, Control Send with Return, or Control Receive node for your business process nodes. Whichever method you choose, you can always access your variables from the Data Palette after they are created. When you select a variable in the list on the Data Palette, its properties are displayed in the Property Editor.

Before you can create an XML variable of a particular XML Schema type, you must first import the XSD file that contains the XML Schema into the WebLogic Integration schemas project. For instructions on importing an XSD files, see Importing Files into the Schemas Project.

Before you can create a non-XML variable of a particular non-XML type, you must first import the MFL file that contains the schema for the non-XML type into the WebLogic Integration schemas project. For instructions on importing an MFL files, see Importing Files into the Schemas Project.

Before you can create a variable of a Java class type, the Java class file must first be available in the WebLogic Workshop project. To learn more about including a Java class in your project, see Using Existing Applications.

To Create a New Variable in the Data Palette

You can create variables using the Add menu on the Variables tab. To learn how to create variables in the node builder, see To Create a New Variable in the Node Builder.

1. If the Variables tab is not visible in WebLogic Workshop, choose View —> Windows —> Data Palette from the menu bar.

The Data Palette, which contains a Variables and a Controls tab, is displayed in the Design View.

2. In the Variables tab, click Add to display the Select Variable Type menu.

A description of the possible variable types options are as follows:

- XML Types

Lists the XML Schemas that are available in your business process project and the untyped XMLObject and XMLObjectList data types.

- Non-XML Types

Lists the Message Format Language (MFL) files available in your business process project and the untyped RawData data type. WebLogic Integration uses a metadata language called Message Format Language (MFL), based on XML, to describe the structure of non-XML data. Every MFL file available in your project is listed in Non-XML Types. Note that an XML Schema representation of each MFL file is built by WebLogic Workshop and is also available in the XML Types listing.

- Java Types

Lists Java primitive data types.

Variables can be created from the Java classes in the current project but the list of available Java classes are not however, listed in the Select Variable pane. To create variables from Java classes, you must explicitly specify the Java class in the Variable type field as described below.

For more detailed descriptions of the data types, see Working with Data Types.

3. From the drop-down menu, select the appropriate variable types from the selected option: XML, NonXML, or Java.

The Create Variable dialog box is displayed with the selected variable type.

4. In the Variable Name field, enter a name for your variable.
5. In the Select Variable Type field, select or in the Variable type field, enter a variable type:

- For a Java class type variable, enter the full package name of the class in the Variable type field. For example, for a class named Book in the package named library, enter: library.Book. (For Java simple types, see step 7.)
- For all other all variable types, select a variable type from the available list.

The Variable type field is populated with the variable type you selected.

6. If you want to assign a default value to your variable, enter it in the Default value field.
7. If your variable is a Java simple type and you want it to be a constant that cannot be updated, select Declare as constant, then enter the constant value in the Default value field. This will create the variable as static and final.

Note: If you select the Declare as constant and leave the Default value field blank, the run time default value used is:
-non-primitive: null
-numbers: 0
-boolean: false
-char: '\0'

8. Click OK to create the new variable.

The Variables tab in the Data Palette is populated with the variable you created; the name and type of the variable is displayed. When you select a variable in the list, the variable properties are displayed in the Property Editor.

To Create a New Variable in the Node Builder

You can create variables directly in the node builder while you are configuring a node's Receive or Send Data tab. To learn how to create variables outside of the node builder, see To Create a New Variable in the Data Palette.

1. In the Receive or Send Data tab, select the Variables Assignment option if necessary.
2. From the Select variables to assign: drop-down menu, select Create new variable.... The Create Variable dialog box is displayed.

Note: The other fields in the dialog box are already populated with the variable types expected by the method you specified on the General Settings tab.

3. In the Variable Name field, enter a name for your variable.
4. If you would like to use a variable of a type other than what is expected by the method you specified on the General Setting tab:

1. Select a variable type option for your variable:
2. XML Types

Lists the XML Schemas that are available in your business process project and the untyped XMLObject and XMLObjectList data types.

3. Non-XML Types

Lists the Message Format Language (MFL) files available in your business process project and the untyped RawData data type. WebLogic Integration uses a metadata language called Message Format Language (MFL), based on XML, to describe the structure of non-XML data. Every MFL file available in your project is listed in Non-XML Types. Note that an XML Schema representation of each MFL file is built by WebLogic Workshop and is also available in the XML Types listing.

4. Java Types

Lists Java primitive data types.

For more detailed descriptions of the data types, see Working with Data Types.

The Select Variable Type field is populated with the variable type you selected.

5. Select or enter a variable type:

- For a Java class type variable in the Variable type field enter the full package name of the class in the Variable type field. For example, for a class named Book in the package named library, enter: library.Book. (For Java simple types, see step 6.)
- For all other all variable types, select a variable type from the available list.

The Variable type field is populated with the variable type you selected.

6. If your variable is a Java simple type and you want it to be a constant that cannot be updated, select Declare as constant, then enter the constant value in the Default value field. This will create the variable as static and final.

Note: If you select the Declare as constant and leave the Default value field blank, the run time default value used is:
-non-primitive: null
-numbers: 0
-boolean: false
-char: '\0'

7. If you want to assign a default value to your variable, enter it in the Default value field.
8. Click OK to create the new variable.

The new variable you created is displayed in the Select variables to assign: drop-down menu in the node builder and is added to the Variables tab in the Data Palette; the name and type of the variable is displayed. When you select a variable in the list, the variable properties are displayed in the Property Editor.

To Convert Application Variable Data Types

The node builders support assigning typed data to untyped process variables, and untyped data to typed process variables in the following ways:

- Typed to Untyped

- You can assign strongly typed XML data (XML Bean) to untyped XML variables (XMLObject).
- You can assign typed non-XML data (MFLObject) to untyped non-XML variables (RawData).

- Untyped to Typed

- You can assign untyped XML data (XMLObject) to strongly typed XML variables (XML Bean).
- You can assign untyped non-XML data (RawData) to typed non-XML variables (MFLObject).

Related Topics

Deleting Variables

Working with Data Types

Assigning MFL Data to XML Variables and XML Data to MFL Variables