Iterate inside an xml envelope

LegacyForumLegacyForum Posts: 1,669 ✭✭
edited December 2016 in SOAtest
Hello All,

I have the following xml file
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope>
<SOAP-ENV:Body>
<Request>
<UpdateReq>
<Operator></Operator>
<Data></Data>
</UpdateReq>
</Request>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

and the possible values for my tags are
Operator = [Galleti, Diogo, Doudou, Jenna]
Data = [Data1, Data2]

I need to permutate between the values. This means I want to create 4*2 = 8 possible xmls. I want to do it via scripting.

How it is done via SOAtest? How can I automatically generate xml files given a set of preconfigured values?

Thanks.
Lefteris
Tagged:

Comments

  • LegacyForumLegacyForum Posts: 1,669 ✭✭
    Hi Lefteris,

    This can be done by using two data sources, one for each set of data. For example, you might have 1 table with a column called "names", which contains rows [Galleti, Diogo, Doudou, Jenna]. Then, the second data source could have a column called "data" and contain rows [Data1, Data2].
    Then you would need to add a Method Tool, which contains a script that copies the values in one of these data sources (say names) to an array of Strings. The return value of the script should be SOAPUtil.getXMLFromString(yourArray); You can then attach an XML Data Bank as an output of the Method Tool, which stores these values (note that it will store values into a special Data Source, called the Generated Data Source).
    Finally, add your SOAP Client tool and choose the other data source as input (data). You can then parameterize your payload against either the "data" data source (for the Data element) or the Generated Data Source for the names. This should produce the combinatorial effect.

    I hope this helps!

    - Brian

    Hello All,

    I have the following xml file
    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope>
    <SOAP-ENV:Body>
    <Request>
    <UpdateReq>
    <Operator></Operator>
    <Data></Data>
    </UpdateReq>
    </Request>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

    and the possible values for my tags are
    Operator = [Galleti, Diogo, Doudou, Jenna]
    Data = [Data1, Data2]

    I need to permutate between the values. This means I want to create 4*2 = 8 possible xmls. I want to do it via scripting.

    How it is done via SOAtest? How can I automatically generate xml files given a set of preconfigured values?

    Thanks.
    Lefteris

  • LegacyForumLegacyForum Posts: 1,669 ✭✭
    Hi Brian,

    I created a Method tool with the following script

    from com.parasoft.api import Application
    from soaptest.api import SOAPUtil
    #Application.showMessage(en_v)

    def test():
    Operator = [Galleti, Diogo, Doudou, Jenna] /* lets forget the first table. this static array looks ok */
    return SOAPUtil.getXMLFromString(Operator)

    and I chained an XML Data Bank.

    This seems to work. I cannot understand your phrase "can then parameterize your payload against either the "data" data source (for the Data element) or the Generated Data Source for the names"

    Can you come again with a tst? I have attached the first phase.

    I am using 5.5.3

    Lefteris
  • LegacyForumLegacyForum Posts: 1,669 ✭✭
    Hi Lefteris,

    I have attached an example .tst file, created with 5.5.3.

    One thing I forgot to mention in my last post is that the XML Data Bank has to write its values to a Writable Data Source. But aside from that, it works as described.

    Note that, in the SOAP Client Form XML view, the Value for Operator and Data have been parameterized, and that the XML Data Bank has saved all of the <z> elements individually. If you change the number of operators, you would need to make sure that the XML Data Bank is updated with the correct number of items. (If it is likely that the number of elements will change, there's a more advanced solution that will support this).

    I hope this helps!
  • LegacyForumLegacyForum Posts: 1,669 ✭✭
    Hi Brian,

    thanks for the quick answer. it looks fine (the writable completed the puzzle.) I will continue to work on
    that in order to provide a general solution.

    Lefteris
Sign In or Register to comment.