Forum Discussion

Martin_Ge's avatar
Martin_Ge
New Contributor
16 years ago

Getting values from old axis code with multirefs

I have to work with old Axis code which produces responses with multiRefs like this:

<state href="#id6"/>

[...]

<multiRef id="id6" soapenc:root="0" [...]>0</multiRef>


Is there an easy way to get at the value of "0" for "state"? Easier than writing a very complex Xpath expression or walking the DOM tree with a groovy script? There are literally dozens of multirefs for each web service method and that kind of thing would get really tedious really soon.
  • Hi Martin,


    There is no built-in support for multiRefs.
    I'm afraid you'll need to handle them manually as you suggested yourself.


    Cheers!
    /Nenad Nikolic a.k.a. Shonzilla
  • Martin_Ge's avatar
    Martin_Ge
    New Contributor
    Thanks for the reply! At least now I know it's not there.

    This is what I came up with so far. Doesn't handle nested multirefs yet but so far that functionality wasn't needed either. Maybe someone can use it.


    def getMultirefValue(String xpath, def holder) {
    def reference = holder[xpath + "/@href"] - "#"
    def valueXpath = "//*/multiRef[@id='" + reference + "']/text()"
    def value = holder[valueXpath]
    return value
    }
  • I have the same problem with a webservice that uses multiRefs.

    What do I have need to do in order to use the code you posted?

    Tom
  • eviware support wrote:

    You will need to use it in a Groovy Script TestStep

    Yes, I have tried that. But I did not succeed in putting together all necessary test steps.

    As far as I see, this method "only" replaces 1 href attribute with its content.
    Somewhere, I would need to add a loop that gets all those hrefs -> how?
    What is the "holder" parameter of this method? Its probably the response of the Request -> how to get hold of that?
    Do I need additional "Property Transfer" test steps ?

    Could someone post a little "cookbook" how to do it all?

    Tom