how do i parse this XML in soapui

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 01:48:59

问题


First of all, i add a properties step with property name response, and i add transfer property step to transfer the response XML to response property in properties step. and here is the groovy Code i wrote to parse this XML and trying to retrieve the seesionId value.but im getting the seesionId null result. how do i do it?

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?

回答1:


Proper XML, such as a SOAP message, has namespaces. To just read a node, you would need:

holder.getNodeValue("//*:sessionId")


来源:https://stackoverflow.com/questions/31990480/how-do-i-parse-this-xml-in-soapui

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!