Initializing Variables
A BPEL process receives, manipulates, and sends data through XML variables. Variables hold the messages exchanged between business partners and data used within the process. All variables are initialized by default before you use them. Initialization preferences are set in the BPEL Properties panel of the Preferences dialog box.
Variable initializers are available for you to review, and if necessary modify, in the Initialization tab of the Properties view.
Viewing variable initializers
You can see the initializer that the Design Studio created for each variable that your process uses. Variables represent inputs and outputs to the BPEL process. To review the initializer:
- In the Outline view, select the variable you want to review. In the Properties view, the Initialization tab becomes available.
- Open the Initialization tab. You can verify that the initializer is in place and is accurate.
- You can modify the initializer by clicking the Initialization icon on the Properties toolbar.
To initialize variables manually
You can choose to initialize variables manually. You initialize a variable by assigning a fixed value to the variable. To manually assign a fixed value to a variable:
- Open the Windows menu, select Preferences, and then BPEL Properties. Verify that the Automatically Initialize Variable option is cleared.
- In the Outline view, select the variable you want to initialize.
- Open the Initialization tab in the Properties view.
- From the Properties view, click Initialize on the toolbar. The Variable Initialization dialog box displays.
Here you can review or modify the initializer and, if needed, clear the Include Optional Content option for this variable
If you choose to initialize variables manually and assign date to a structured variable before you initialize it, you will be prompted to generate an initializer for the variable. Using the Variable Initialization dialog box, you can view an XML document that conforms to the schema type of the variable and insert default values or change the XML, if necessary.
Initialization options
To set these options, open the Window menu, select Preferences, and open the BPEL Properties page.
Automatically Initialize Variables which is set by default, provides initializers for input and output variables. Clear this option to initialize variables manually.
Include Optional Content recognizes that certain elements or attributes are optional. When an element is optional it means that in the XML schema it has a minOccurs attribute of 0 and a maxOccurs attribute of 1 or greater. This indicates that the element doesn't have to be there. If an element is required it will have a minOccurs attribute of 1. This option is checked by default.
If you plan to reference any element in the variable then it must be included in the initializer. Element names cannot contain spaces. Required components may be tagged as optional. This is a common error when working with Web services. You can usually count on the generated initializer to make the best selection, and it is a good idea to not modify this option.
There are some right-click options available from the XML editor of the Variable Initialization dialog box that are not supported in this version of Process Design Studio. These include: Add to Snippets and Validate.
Handling schemas that contain choices
Whenever schema containing a <choice>
element is involved you must edit the initializer manually. The variable initialization editor assumes that the first choice is always correct. See w3schools.com for more information on schema choice elements.
Related Topics