soapUI - embbed XML in a request using groovy

2019-05-30 14:20发布

问题:

I'm making test cases on soapUI, on some steps I would use a REST quest and put XML code in the lower pane, something like

<dataList>
    <data>
        3.1416
    </data>
    <data>
       5.11
    </data>
</dataList>

But I need to get the response and store the results that will be contained inside the XML text of the response, to verify that the web service is executing proper operations and then send more requests using the received results.

Thanks everyone!

回答1:

I could solve this using properties and Property Transfer

  1. Add a property to the TestCase in the Custom Properties tab

  2. Add a property Transfer step

    2.1 As source select the test step with the response where are the results to store

    2.2 In the drop down list of property select ResponseAsXml

    2.3 In text are of the source write the path of the xml tag like: /dataList/data

    2.4 As target select the test case where was added the custom property of (1)

    2.5 As target property select the name of the custom property added.

Thank you very much to everyone for your prompt answers :) As soon as I have better reputation I'll post some pictures.



回答2:

A Groovy script test step which goes with your test suite as below:

def grUtils = new com.eviware.soapui.support.GroovyUtils(context)
def holder = grUtils.getXmlHolder(
               context.expand('${TestStep#Response#//node}'))

println holder.getXml()

//where TestStep = Your test Step where you get the response  
//node = The xml node you want to pick. In your case it is "dataList"