如何在soapUI中使用XmlSlurper

| 我有以下在groovyconsole中运行的groovy脚本,它运行得很好。我在xml响应中找到特定节点的子节点数,并打印出每个子节点所需的值。
def path = new XmlSlurper().parse(new File(\'C://SoapUI//ResponseXML/Response.xml\'))
NumberOfPositions =  path.Body.GetPositionsAggregateResponse.GetPositionsAggregateResult.AccountPositions.Securities.Positions.children().size()
for(def i=0; i<NumberOfPositions; i++){
println i

println  path.Body.GetPositionsAggregateResponse.GetPositionsAggregateResult.AccountPositions.Securities.Positions.PositionSummary[i].Legs[0].PositionAggregate[0].PositionID[0].text()
println  path.Body.GetPositionsAggregateResponse.GetPositionsAggregateResult.AccountPositions.Securities.Positions.PositionSummary[i].Legs[0].PositionAggregate[0].AccountID[0].text()

}
我想在soapUI中执行相同的任务,但是无法使用groovyutils使其如此处所述:http://www.soapui.org/Scripting-Properties/tips-a-tricks.html 1)如何解析从我的请求到xmlSlurper的xml响应? def path = new XmlSlurper()。parse(?) 2)我也可以在soapUI中使用上面的相同代码吗? 任何帮助表示赞赏。谢谢!     
已邀请:
(1) 要解析响应消息,您可以尝试以下操作:
def response = context.expand( \'${TestRequest#Response}\' )
def xml = new XmlSlurper().parseText(response)
“ 2”代表发送SOAP请求消息的测试步骤的名称。 (2) 是的,soapUI应该能够处理任何Groovy代码。     
您可以在SoapUI中直接使用普通的Groovy脚本。检查此链接,可能会对您有所帮助。但是,请记住,在SoapUI中编写脚本时,您需要使用\“ log.info \”而不是\“ println \”。     

要回复问题请先登录注册