cathyzhang
15 years agoNew Contributor
"holder.declareNamespace" failed in SOAPUI 2.5
Hi,
I want to get XML node value from MockRequest. So I need use XmlHolder. But there is an error " Prefix ns has not been declared".
Then I used below code to test in SOAPUI2.5 and Pro 3.6.1. I'm surprised that it is successed in Pro 3.6.1.
Could you please confirm below code can't be used in SOAPUI2.5? Thanks.
def xml = '''<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<RunScript xmlns="http://tempuri.org/">
<optionObject>
<EntityID>5</EntityID>
<Facility>98</Facility>
</optionObject>
</RunScript>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>'''
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = groovyUtils.getXmlHolder( xml )
holder.declareNamespace( 'ns', 'http://tempuri.org/')
log.info holder.getNodeValue( "//ns:Facility")
log.info holder.getNodeValue( "//ns:EntityID")
-------------
Response
Pro 3.6.1
Thu Jan 27 22:40:15 CST 2011:INFO:98
Thu Jan 27 22:40:15 CST 2011:INFO:5
2.5 error:
java.lang.RuntimeException: net.sf.saxon.trans.XPathException: XPath syntax error at char 13 in {//ns:Facility}: Prefix ns has not been declared
I want to get XML node value from MockRequest. So I need use XmlHolder. But there is an error " Prefix ns has not been declared".
Then I used below code to test in SOAPUI2.5 and Pro 3.6.1. I'm surprised that it is successed in Pro 3.6.1.
Could you please confirm below code can't be used in SOAPUI2.5? Thanks.
def xml = '''<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<RunScript xmlns="http://tempuri.org/">
<optionObject>
<EntityID>5</EntityID>
<Facility>98</Facility>
</optionObject>
</RunScript>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>'''
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = groovyUtils.getXmlHolder( xml )
holder.declareNamespace( 'ns', 'http://tempuri.org/')
log.info holder.getNodeValue( "//ns:Facility")
log.info holder.getNodeValue( "//ns:EntityID")
-------------
Response
Pro 3.6.1
Thu Jan 27 22:40:15 CST 2011:INFO:98
Thu Jan 27 22:40:15 CST 2011:INFO:5
2.5 error:
java.lang.RuntimeException: net.sf.saxon.trans.XPathException: XPath syntax error at char 13 in {//ns:Facility}: Prefix ns has not been declared