简体   繁体   English

soapUI - 使用groovy在请求中嵌入XML

[英]soapUI - embbed XML in a request using groovy

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 我正在使用soapUI进行测试用例,在某些步骤中我将使用REST任务并将XML代码放在下部窗格中,类似于

<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. 但我需要获取响应并存储将包含在响应的XML文本中的结果,以验证Web服务是否正在执行正确的操作,然后使用收到的结果发送更多请求。

Thanks everyone! 感谢大家!

I could solve this using properties and Property Transfer 我可以使用属性和Property Transfer来解决这个问题

  1. Add a property to the TestCase in the Custom Properties tab 在“自定义属性”选项卡中将属性添加到TestCase

  2. Add a property Transfer step 添加属性转移步骤

    2.1 As source select the test step with the response where are the results to store 2.1作为源,选择具有响应的测试步骤,其中存储结果

    2.2 In the drop down list of property select ResponseAsXml 2.2在属性的下拉列表中选择ResponseAsXml

    2.3 In text are of the source write the path of the xml tag like: /dataList/data 2.3在源文本中写入xml标记的路径,如:/ dataList / data

    2.4 As target select the test case where was added the custom property of (1) 2.4作为目标选择测试用例,其中添加了(1)的自定义属性

    2.5 As target property select the name of the custom property added. 2.5作为目标属性,选择添加的自定义属性的名称。

Thank you very much to everyone for your prompt answers :) As soon as I have better reputation I'll post some pictures. 非常感谢大家的快速回答:)一旦我有更好的声誉,我会发布一些图片。

在此输入图像描述在此输入图像描述

A Groovy script test step which goes with your test suite as below: Groovy脚本测试步骤与您的测试套件一起使用,如下所示:

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"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM