Forum Discussion

Gothenburgare's avatar
15 years ago

Use response values in test step

Hi all, I am quite new to SoapUI and am currently trying to learn what it can do.

In my work we have a webservice for network equipment that I want to try to use Soap to do operations instead of perl scripting. Lets say I query this service for active ports under a node and get back a response like this :


    <soapenv:Body>
    <getLogicalPortsResponse xmlns="uri://manufacturer.com/service/4.0">
    <logicalPort xmlns="">Goteborg-FD:1-1-1-2</logicalPort>
    <logicalPort xmlns="">Goteborg-FD:1-1-1-4</logicalPort>
    etc etc etc


If I want to do a testcase and use a loop to send a new query command for each of these logicalPorts in the answer, can this be done? Can it be done in both pro and free?

Regards Micael

1 Reply

  • vijayevol's avatar
    vijayevol
    Occasional Contributor
    If the test step request name is "XXXXXXX"

    //Getting the values from a response

    groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
    XMLHolder = groovyUtils.getXmlHolder("XXXXXXX#Response")
    //"ports" is a array variable
    def ports = XMLHolder.getNodeValues("//logicalPort")

    //Setting the value to a request

    XMLHolder = groovyUtils.getXmlHolder("XXXXXXX#Request")
    //ports[0] holds the first port value, ports[1] holds the second port value and so on....
    XMLHolder.setNodeValue("//logicalPort", ports[0]);
    XMLHolder.updateProperty()