title: traversing a BPEL array
body: <p>I need to traverse an array (input to BPEL) in java embed activity and need to generate a response (output variable) of BPEL process.</p>
  
  <p>I am using Jdeveloper and SOA 11g</p>
  
  <p>following is my xsd</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://xmlns.oracle.com/BPELInpuandOutPutArray_jws/Project1/BPEL_input_output_array" xmlns="http://www.w3.org/2001/XMLSchema"&gt;
        &lt;element name="process"&gt;
              &lt;complexType&gt;
                    &lt;sequence&gt;
                          &lt;element name="simpleinput" type="string"/&gt;
                          &lt;element name="arrayofObjects" maxOccurs="unbounded" nillable="true"&gt;
                                &lt;complexType&gt;
                                      &lt;sequence&gt;
                                            &lt;element name="input1" type="string"/&gt;
                                            &lt;element name="input2" type="string"/&gt;
                                      &lt;/sequence&gt;
                                &lt;/complexType&gt;
                          &lt;/element&gt;
                    &lt;/sequence&gt;
              &lt;/complexType&gt;
        &lt;/element&gt;
        &lt;element name="processResponse"&gt;
              &lt;complexType&gt;
                    &lt;sequence&gt;
                          &lt;element name="arrayofObjectsoutput" maxOccurs="unbounded" nillable="true"&gt;
                                &lt;complexType&gt;
                                      &lt;sequence&gt;
                                            &lt;element name="output1" type="string"/&gt;
                                            &lt;element name="output2" type="string"/&gt;
                                      &lt;/sequence&gt;
                                &lt;/complexType&gt;
                          &lt;/element&gt;
                    &lt;/sequence&gt;
              &lt;/complexType&gt;
        &lt;/element&gt;
  &lt;/schema&gt;
  </code></pre>
  
  <p>so far I am able to manage for traversing in input array</p>
  
  <pre><code>oracle.xml.parser.v2.XMLElement e1=
  (oracle.xml.parser.v2.XMLElement)getVariableData("inputVariable","payload","/client:process/client:arrayofObjects[1]/client:input1"); 
  
  System.out.println(e1.getFirstChild().getNodeValue());
  </code></pre>
  
  <p>But my business requirement is to based on some logic set the values in output array.
  for this I used following sample code.</p>
  
  <pre><code>for(int i=1; i &lt; 4 ;i++) 
  { 
  setVariableData("outputVariable","payload","/client:processResponse/client:arrayofObjectsoutput['i']/client:output1",i);
  setVariableData("outputVariable","payload","/client:processResponse/client:arrayofObjectsoutput['i']/client:output2",i);
  }
  </code></pre>
  
  <p>My feeling is array would be created of length 3 and value will be settes(1,1) (2,2) (3,3) but at the output value is only (3,3) .
  please tell me how can i achieve the same.</p>
  
  <p>sample code will be appreciated.</p>