i'm using WSO2 ESB 4.8.1 and in particular way i'm facing up to script mediator. I need to resolve a doubt. I need to build a payload made like this way:
<response>
<urls>
<url>http://myfirsturl</url>
<url>http://mysecondurl</url>
<url>>http://mythirdurl</url>
</urls>
</response>
In my script mediator i wrote this snippet code:
<script language="js">
...
...
var clinvarPayload = <response><urls></urls></response>
for (i = 0; i < myArray.length; ++i){
clinvarPayload..*::urls.url = myArray[i]
}
mc.setPayloadXML(clinvarPayload);
My problem is that after the end of the for loop i get the response containing just the last myArray element, i.e:
<response>
<urls>
<url>http://mythirdurl</url>
</urls>
</response>
What's wrong with my code? How can i append the myArray elements?