[英]How to get the value of a webservice response in soapUI?
我在soapUI
有2個依賴步驟。 我想為第二個請求自動使用在第一個響應中返回的值。
我可以使用${FirstStep#Response}
來引用整個第一響應。 但是如何繼續?
假設響應如下,我想提取標記Key
的值:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<LoginResponse xmlns="http://schemas/WebServices">
<Key>asdasdasd</Key>
</LoginResponse>
</s:Body>
</s:Envelope>
有兩種方法:
1.使用上下文引用
e.g `context.expand( '${RestTestStep#Response//xpathToDataNeeded}')`
XmlSlurper
對其進行XmlSlurper
。 def responseXml = testRunner.testCase.testSteps["StepName"].testRequest.response.getResponseContent();
def xmlSlurperObj = new XmlSlurper().parseText(responseXml );
def xmlSlurperObj= new XmlSlurper().parseText(xml).declareNamespace(s:"http://schemas.xmlsoap.org/soap/envelope/");
log.info xmlSlurperObj.Body.LoginResponse.Key.text();
學習XmlSlurper的很好鏈接
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.