Forum Discussion

jkrier's avatar
jkrier
Regular Contributor
8 years ago

DataSource-XML not returning data

I have an XML response that loos like this

 

<soap:Envelope>
   <soap:Body>
      <getDocumentNamesResponse>
         <documentName>AAABRIDGE</documentName>
         <documentName>WSCLIENT</documentName>
         <documentName>XML_AGENT</documentName>
         <documentName>ZZZTESTING2</documentName>		 
      </getDocumentNamesResponse>
   </soap:Body>
</soap:Envelope>

I want to iterate over this response with a DataSource/DataSourceLoop

So I configured DataSource-XML step as

 

Property = 'documentName'

Source Step = XML

Source Property = Response

Row Xpath = //ns1:getDocumentNamesResponse[1]/ns1:documentName[1]

Column Xpaths = documentName/text()

 

But this returns nothing

 

I also tried

 

Changing the Column Xpath to just "ns1:documentName[1]" and now it returns the first documentName but nothing else. I tried changing it to ns1:documentName[] and ns1:documentName but then nothing is returned.

 

Row Xpath = //ns1:getDocumentNamesResponse[1]/ns1:documentName

Column Xpath = ns1:documentName

this returned 100 empty rows (100 is the total count, I manually shortened the xml to make it easier to read on here)

 

Row Xpath = //ns1:getDocumentNamesResponse[1]

Column Xpath = ns1:documentName

This returned just the first documentName element

 

If anyone can offer any advice i'd appreciate it.

  • Well I managed to get it to work with that note.

     

    Row XPATH should be (including whatever namespaces you have, so ns1?)

     

    //ns1:getDocumentNamesResponse[1]/ns1:documentName

     

     

    Column XPATH:

    text()

     


    Can you try that?

    (Edit for missing / on row xpath)

     

  • jkrier's avatar
    jkrier
    8 years ago

    You really got my hopes up.

     

    Made the Row Xpath

    declare namespace ns1='mynamespace';

    /ns1:getDocumentNamesResponse[1]/ns1:documentName

     

    Column XPath

    text()

     

    But I get 0 results

     

    So then I tried

    declare namespace ns1='mynamespace';

    //ns1:getDocumentNamesResponse[1]/ns1:documentName

     

    So the difference is the slashes, "//" versus "/" and guess what? IT WORKS!!!!!!

     

    AAABRIDGE
    ADDMONTHLY
    ADDRESS_VALIDATION
    ATLAS_SALESFORCE_AUTHSERVICE
    AUTHENTICATION_SERVICE
    AUTHORIZATION
    BATCH_PROCESSING_SERVICE
    BILLING
    BULK_RMA
    BULK_RMA_GUI

     

    I really can't thank you enough for all the time you spent helping me. This will greatly enhance my tests and something I've been wanting to do for a long time but it just never worked for me so I would work around it.

    • sanj's avatar
      sanj
      Super Contributor

      What are you trying to do?

      this sounds like something that can be easily resolved with groovy scripting instead of datasource

      • jkrier's avatar
        jkrier
        Regular Contributor

        I am trying to use built in functionality with SoapUI Pro. Yes, I know I could do this with some scripting but I have paid for a pro license so I expect that these features should work.

         

        I am trying to use an XML response as my DataSource to use in conjunction with a DataSource Loop. This is basic functionality with the pro version (I've just never had a need before).

         

        So yeah, could I fix it with scripting, yes, I could.

         

        Do I want to do that, no, I do not.