Chris Ridmann
Chris Ridmann

Reputation: 2896

WSO2 ESB Store array of results in a property

Basically I am getting an array of results from a data service call and I need to pass this array into java. I am trying to store the array of results in a property mediator somehow, and then pass this into java.

Here is an example of the data service results:

<testResponse>
   <result>
      <PARAM1>0</PARAM1>
      <PARAM2>20</PARAM2>
      <PARAM3>40</PARAM3>
   </result>
</testResponse>

And here is an example of my java function that I am calling:

public static String testFunction(int[] array);

And here is a payload for this java function:

<payloadFactory>
        <format>
            <p:testFunction xmlns:p="http://test.com">
                <xs:array xmlns:xs="http://test.com">$1</xs:array>
           </p:testFunction>
        </format>
        <args>
            <arg xmlns:ns="http://org.apache.synapse/xsd" expression="$ctx:PROPERTYARRAY"/>
        </args>
</payloadFactory>

I am confused about how to set "PROPERTYARRAY".

Right now I am doing something like:

<property xmlns:ns="http://org.apache.synapse/xsd" name="PROPERTYARRAY" expression="//testResponse/result/" scope="default" type="STRING"/>

And the log for this is "02040".

How can I get this in array format and send to my java function?

Upvotes: 1

Views: 1638

Answers (1)

Ratha
Ratha

Reputation: 9692

Try like this;

 <property name="propertyarray" expression="$body"/>

Upvotes: 1

Related Questions