I have following code snippet:
<set-variable value="#[]" doc:name="Add Response"
doc:id="05bb1a62-3826-41dc-b4bb-8ef27e5b99cb"
variableName="responseArray" />
<foreach doc:name="For Each"
doc:id="1bf6620c-9156-4580-81e4-53f80d66d1da"
collection="#collectionOfRequests">
<wsc:consume operation="operation"
doc:name="Call Service" doc:id="6d44833e-9317-4dba-8011-7844d0e207dd"
config-ref="Web_Service_Consumer_Config" />
<set-variable value="#vars.responseArray << (write(payload, 'application/xml'))" doc:name="Add Response" doc:id="a6516eff-a3c9-436c-85f5-79ce8be44608" variableName="addResponse" />
</foreach>
The issue is, the response xml is not added to responseArray. I tried using dataweave but got the same issue.
What is the right way to add a xml or json payload to an array so i can do an aggregation mapping?
Hi @Xin Liu ,
Everything is fine just change the expression as following for your set variable, which you have inside foreach scope:
#[vars.responseArray + payload]
I hope it works for you.
Regards,
Lalit Panwar