Forum Discussion

tadudek's avatar
tadudek
Occasional Contributor
5 years ago

How can I map a datasource to values in a REST XML content (xml element values)?

How can I map a datasource to values in a REST XML content (xml element values)?

 

I have a datasource with values; say parm1:value, parm2:value, parm3:value, etc. I have a REST POST request with XML content. I need to map the values in the datasource to the xml elements, so that each request iterates through my datasource (excel document) and fills the xml element values. 

 

I can't seem to find how I map them accordingly. 

    • tadudek's avatar
      tadudek
      Occasional Contributor

      nmrao 

      So, I already did go through these. I already watched the video you link as well. Thank you. The video you mention is something about TestComplete. I'm running these tests in SoapUI Pro. I don't have TestComplete. I'm not entirely sure why you think the testcomplete video does anything to describe how to map to a REST XML payload. The other video I found at least has the basics and infers that you can map to the payload, but the tutorial and concepts page do nothing to describe how to map to the XML payload explicitly. 

       

      The issue, is that if you have an XML payload, that would get populated by the datasource, it doesn't seem to be possible to populate varying amounts of xml sub-elements that would be 1-*. In example in my first request I have 1 widget to query, and in my second request, I have 3 widgets. My widgets will vary in each request. So, within the XML payload, if you have a schema, you'd see:

       

      Datasource record #1: widget:#123

      Datasource record #2: widget:#123,widget:#124,widget:#125

       

      The widgets here are just reoccurring elements within the widgets elements.

      #1: <widgets><widget>#123</widget></widgets>

      #2: <widgets><widget>#123</widget><widget>#124</widget><widget>#125</widget></widgets>

       

      The tutorials don't provide insight to be able to populate an XML payload that varies #'s of elements by request. Ideally, I'd like to find a way to populate the datasource, and have the test create any number of sub-elements of widgets in this case based on the number of widgets in the spreadsheet. 

       

      Thanks! 

       

    • richie's avatar
      richie
      Community Hero

      Hi tadudek 

       

      if I understand correctly you want to populate a spreadsheet with multiple tag values (multiple for a single POST request) so a single excel file contains all data for multiple tests in a loop?  Is that correct?

       

      If you review the following link (and any embedded links within) - this should give you exactly what you need - the link is here

       

      Cheers,

       

      rich

       

       

      • tadudek's avatar
        tadudek
        Occasional Contributor

        Rich, richie 

         

        I posted this in a sepearate response to the "solution". 

         

        The issue, is that if you have an XML payload, that would get populated by the datasource, it doesn't seem to be possible to populate varying amounts of xml sub-elements that would be 1-*. In example in my first request I have 1 widget to query, and in my second request, I have 3 widgets. My widgets will vary in each request. So, within the XML payload, if you have a schema, you'd see:

         

        Datasource record #1: widget:#123

        Datasource record #2: widget:#123,widget:#124,widget:#125

         

        The widgets here are just reoccurring elements within the widgets elements.

        #1: <widgets> <widget>#123</widget> </widgets>

        #2: <widgets> <widget>#123</widget><widget>#124</widget><widget>#125</widget> </widgets>

         

        The tutorials don't provide insight to be able to populate an XML payload that varies #'s of elements by request. Ideally, I'd like to find a way to populate the datasource, and have the test create any number of sub-elements of widgets in this case based on the number of widgets in the spreadsheet.