使用 groovy 更改 SoapUI 请求
我是 SoapUI 的新手。我有几个相互依赖的测试步骤。因此,我使用 XML-Slurper 从响应“deliverData”读取数据并将它们存储在我的 TestCase 的属性中。
def xml = new XmlSlurper().parseText(response)
def response = context.expand( '${deliverData#Response}' )
def ID = xml.Body.DeliverDataResponse."pollingId";
testRunner.testCase.setPropertyValue("pollingID",ID.text());
现在我想将 pollingID 用于另一个请求,就像
<soapenv:Body>
<DeliverRequest>?</DeliverRequest>
</soapenv:Body>
我读过 http://groovy. codehaus.org/Updating+XML+with+XmlSlurper 但我不知道如何将操纵的数据存储到请求中?我什至不知道如何更新。 希望有人可以帮助我,我真的不喜欢使用脚本,我更喜欢普通的java编码:) 多谢! 约翰
回答: 这就是它的工作原理,但不再适用于 xmlslurper。
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = groovyUtils.getXmlHolder( "DeliverStatus#Request" );
holder.setNodeValue( "//DeliverRequest", "200" );
holder.updateProperty();
I'm new to SoapUI. I have a few TestSteps depending on each other. So i used the XML-Slurper to read Data from a response "deliverData" and stored them in my TestCase's properties.
def xml = new XmlSlurper().parseText(response)
def response = context.expand( '${deliverData#Response}' )
def ID = xml.Body.DeliverDataResponse."pollingId";
testRunner.testCase.setPropertyValue("pollingID",ID.text());
Now i want to use the pollingID for another request which like this
<soapenv:Body>
<DeliverRequest>?</DeliverRequest>
</soapenv:Body>
I read http://groovy.codehaus.org/Updating+XML+with+XmlSlurper but I do not see how to store manipulated data into the request? I'm not even sure about how to update.
Hope anybody can help me, i really do not like working with scripts, i prefer normal java coding:)
Thanks a lot!
john
ANSWER:
this is how it works, but not with the xmlslurper any more.
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = groovyUtils.getXmlHolder( "DeliverStatus#Request" );
holder.setNodeValue( "//DeliverRequest", "200" );
holder.updateProperty();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
下面的代码可以帮助您解决问题。
The below code may help you sort your issue.
您拥有属性
pollingID
,只需在另一个 SOAP 请求中使用该属性值,如下所示。它可能会从该属性中获取数据,并且您可以在整个测试用例中使用它[属性]。
如果您想在测试用例之间共享数据,请将其存储为测试套件属性,并在任何测试用例中像
${#TestSuite#Property.name}
一样使用它。You have property
pollingID
and just use that property value in another SOAP request, like the below.it might fetch data from that property and you can use it [property] throughout the Test Case.
If you want to share data between Test cases store it as Test suite property and use it like
${#TestSuite#Property.name}
in any of the test case.