Avatar billede fredand Forsker
19. oktober 2009 - 13:09 Der er 1 kommentar og
1 løsning

How to extract an element with XPath?

Hello Guys!

I'm struggling with a TestCase in SoapUI 3.0.1 (Free).
The idea is to shoot a request, and from the response extract a value and put in to an other request.

The response I got from the first request looks like:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Body>
      <_:save xmlns:_="http://www.xyz.se/wsdl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.xyz.se/types">
        <_:a>
            <b/>
            <c>
              <epost>a@b.com</epost>
              <tekniskNyckel>54132737</tekniskNyckel>
            </c>
        </_:a>
      </_:save>
  </soapenv:Body>
</soapenv:Envelope>

Now I would like to extract the "tekniskNyckel" and put into my next request.

I have tried to extract it like:
declare namespace soap='http://schemas.xmlsoap.org/soap/envelope/';
declare namespace ns1='http://www.xyz.se/types';
declare namespace ns2='http://www.xyz.se/wsdl';
ns1:a/c/tekniskNyckel

But it does not manage to extract anything when I run it in SoapUI.

So if any one got any experiance about this please let me know.

Best regards
Fredrik
Avatar billede Slettet bruger
19. oktober 2009 - 13:21 #1
I don't know how SoapUI works, but you need to prefix all elements along the path, not just the first - from what you've supplied, I'd try with something like this:

"ns2:a/ns1:b/ns1:c/ns1:tekniskNyckel"

/Chriztian
Avatar billede fredand Forsker
20. oktober 2009 - 09:07 #2
Hello Chriztian!

Thanks for your reply, please give a svar so I can reward you.

I never manage to use it with namespaces but I found out that:

// = Searches for any node, regardless of where the nodes position is in the document.

Then my search string gets to be:
//tekniskNyckel


Best regards
Fredrik
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester