Nov 2, 2008

The lost (collaxa) BPEL-tutorials: 112.Arrays

If you do not know how to iterate over an array, you should read this tutorial:

To model an array with XML you have to create the following XSD:



The element line-item is modelled like this:

<element name="line-item" type="tns:line-itemType" maxOccurs="unbounded"/>

Here the BPEL of this collaxa-tutorial:

If you take a look at the sample code, it works like this:

  1. create a xpath-expression via concat
  2. use this xpath-expression inside another expression
  3. increment the iterator-variable
That's all:

concat('/tns:invoice/tns:line-item[',bpws:getVariableData('iterator'),']/tns:line-total')
is evaluated at runtime to:
/tns:invoice/tns:line-item[1]/tns:line-total
and inserted
bpws:getVariableData('input','payload','/tns:invoice/tns:line-item[1]/tns:line-total')

Another way is to write just
bpws:getVariableData('input','payload','/tns:invoice/tns:line-item[$iterator]/tns:line-total')
which is much easier...

One nice thing with this 112.Arrays example is, that after deployment you find the BPELConsole already filled with parameters:


How can this be achieved? After deployment you can use the checkbox "Save Test" for the first invoke and after that you get this parameters each time filled in.
In this example just take a look at the bpel.xml:


Inside the bpel.xml you can put the default data for the BPELConsole inside this CDATA:
<property name="defaultInput"><![CDATA[
<mydata>parameter1</mydata>
]]></property>


No comments:

Post a Comment