SOAP connector response on a select widget

1
0
-1

I'm having some trouble using the data I got from a SOAP connector in a "Select" type widget in the UI Designer.
With the following script:

import groovy.xml.XmlUtil def xml = responseDocumentBody.getElementsByTagName("IT_BARNIZ_INT").findAll() String barnizInterior = xml.toString() return barnizInterior;

I get this string:

[<?xml version="1.0" encoding="UTF-8"?>

100
001
Agresivos


100
002
Porcelánico


100
003
Porcelánico Agresivo


100
004
BPANI


]

How can I transform this into a object or list I can use in the UI Designer? Ex. transforming it into a json.

1 answer

1
0
-1
This one is the BEST answer!

I finally got it working mapping the xml to a java.util.collection:

import groovy.json.JsonBuilder;
import groovy.xml.XmlUtil

def responseBody = new XmlSlurper().parseText(XmlUtil.serialize(responseDocumentBody.getDocumentElement()))

List listaMaestro = new ArrayList();
def builder = new JsonBuilder();
def i=0;

while (responseBody.IT_ZONAS_FAO.item[i].MANDT.toString() != ""){
def lineaLista = builder {
MANDT responseBody.IT_ZONAS_FAO.item[i].MANDT.toString()
CODIGO_ZONA responseBody.IT_ZONAS_FAO.item[i].CODIGO_ZONA.toString()
DESCRIPCION responseBody.IT_ZONAS_FAO.item[i].DESCRIPCION.toString()
}
listaMaestro.add(lineaLista);
i = i+1;
}
return listaMaestro

There's probably a better way to do this. But it's working.

Notifications