Ask a Question

[Resolved]Getting namespace information from response

BA_Service_Haus
Regular Contributor

[Resolved]Getting namespace information from response

Hi,

for a certain reason I have to read all the namespace declarations of node <soapenv:Envelope>.
What I need is an array or map where I can get each namespace-alias (eg. "n1") and the namespace value (e.g. "http://...")

It tried al lot, but as I'm new to Groovy, I didn't find a solution yet.
Can you give me a hand?

Best regards
Nico
1 REPLY 1
BA_Service_Haus
Regular Contributor

Re: Getting namespace information from response

Hi all,

in the meanwhile I found this solution:

def xml = new XmlSlurper().parseText(messageExchange.responseContentAsXml)
def xmlClass = xml.getClass()
def gpathClass = xmlClass.getSuperclass()
def namespaceTagHints = gpathClass.getDeclaredField("namespaceTagHints")
namespaceTagHints.setAccessible(true)

namespaceTagHints.get(xml).each {item ->
log.info "$item.key = $item.value"}


Best regards
cancel
Showing results for 
Search instead for 
Did you mean: