Hi,
I want to adding dynamically an array elements in an existing XML element in my input parameters of my post SOAP request, but I stuck how to do it.
Here’s what I have done so far:
In the modeler input parameter I added my SOAP payload which contains:
<set: MyParentElement>${myParentElement}</set: MyParentElement>.
in order to get at the end (Dynamically) something like:
<set: MyParentElement>
<sch: child> child1</sch:child>
<sch: child> child2</sch:child>
<sch: child> child3</sch:child>
</set: MyParentElement>.
In my delegate where I create the payload:
public void execute(DelegateExecution execution) throw Excepltion{
…
String myParentElement = createXmlChilds(execution);
execution.setVariable(“set:MyParentElement”, myParentElement);
…
}
This method should add an array of elements, and which I’m stuck with.
public String createXmlChilds(DelegateExecution execution){
// I want to get the parent element but when I use SprinXmlTreeElement i got cannot be resolved to a type
SprinXmlTreeElement parentElement = XML("<MyParentElement/>");
// getting the childs from a JSONArray
SprinXmlTreeElement child1 = XML("<child/>");
SprinXmlTreeElement child2 = XML("<child/>");
SprinXmlTreeElement child3 = XML("<child/>");
// Convert the child’s array to a XML String and update the parent
parentElement.append(child1, child2, child3);
}
Can anyone help, please, how to achieve all above? or tell me if there is any missing configuration that needs to be done? or if there is a simpler way to achieve what I need?
Thanks in advance
Sab