Forum Discussion

Gilbert_Pilz's avatar
Gilbert_Pilz
New Contributor
13 years ago

XML translation of JSON is arbitrarily namespace qualified

Then I use soapUI to GET a resource with a JSON representation, the XML translation of that representation gets a default XML namespace that corresponds to the URL of the resource. For example:

<Response xmlns="http://fooble.example.com/campSrv/ApplicationComponentTemplate/13">

If you are trying to test a HATEOS-oriented service that uses arbitrary URLs (i.e. URLs that can change with every restart of the service), namespace qualifying the XML in this manner makes writing test scripts very difficult. I can't know, a priori, what the namespace of the response is going to be so writing XPATH expressions against this response is difficult. You have to use XPATH functions to work around the fact that you don't know the namespace URI, like so:

//*[local-name() = 'href' and ../../.[local-name() = 'applicationComponents'] and (../*[local-name() = 'name' and contains(text(), 'sample') ] ) ]


Needless to say, this is quite cumbersome and, though I'm not sure yet, probably has some limitations that you wouldn't see if the response were qualified with a knowable namespace URI.

1 Reply

  • I might have figured a work-around for this problem. If I stash the URI of the resource that I use for my initial request in a property, I can expand that property in a namespace declaration like so:

    declare namespace ns1="${assemblyURI}";
    //ns1:assemblyTemplate/ns1:href/text()


    So far, it seems to be working.