Forum Discussion

BA_Service_Haus's avatar
BA_Service_Haus
Regular Contributor
12 years ago

[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

  • BA_Service_Haus's avatar
    BA_Service_Haus
    Regular Contributor
    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