首先,我添加了一个带有属性名称响应的属性步骤,并添加了传输属性步骤以将响应XML传输到属性步骤中的响应属性。这里是我编写的groovy Code来解析这个XML并尝试检索seesionId值。但是我得到了seesionId null结果。我该怎么做?
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = groovyUtils.getXmlHolder("Properties#response")
log.info "sessionId: " + holder.getNodeValue("//sessionId")
log.info holder['//sessionId']
OUTPUT:
Wed Aug 12 10:50:58 GMT+04:00 2015:INFO:xml=<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<signInResponse xmlns="http://..../analyticalserver">
<return xsi:type="authResponseEntryWrapper">
<status>true</status>
<dateTimeEnd>1409726051</dateTimeEnd>
<sessionId>fab37e3a8e38a4981291bab0611fb8aad7af54a0</sessionId>
</return>
</signInResponse>
</soap:Body>
</soap:Envelope>
Wed Aug 12 10:50:58 GMT+04:00 2015:INFO:SET sessionID: null
why sessionID is null?
答案 0 :(得分:1)
适当的XML(例如SOAP消息)具有名称空间。要只读取节点,您需要:
holder.getNodeValue("//*:sessionId")