我如何在soapui中解析这个XML [英] how do i parse this XML in soapui
本文介绍了我如何在soapui中解析这个XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def holder = groovyUtils.getXmlHolder (Properties#response)
log.infosessionId:+ 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/XMLSchemaxmlns: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
为什么sessionID为空?
解决方案
正确的XML如SOAP消息具有命名空间。要读取节点,您需要:
holder.getNodeValue(// *:sessionId)
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?
解决方案
Proper XML, such as a SOAP message, has namespaces. To just read a node, you would need:
holder.getNodeValue("//*:sessionId")
这篇关于我如何在soapui中解析这个XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文