Forum Discussion

Mis3's avatar
Mis3
Frequent Contributor
4 years ago

New to SoapUI

I am new to SoapUI (v5.5) but I did, in a regular basis, send XML requests from my laptop to other systems via SoapUI.  Our vendors supplied me with the WSDL as well as the actual requests.  

Is there any way SoapUI can read a data file in my laptop and sends the same XML request to an external system one by one?  More specifically, there are only one variable in the XML request and I have to send this request to update multiple records in an external table.   So, one variable, same request to one destination. 

 

Sorry if I am not using the right terminologies.  I think the proper terminology for variables is “property”. 

9 Replies

  • richie's avatar
    richie
    Community Hero
    Hey Mis3,

    So,i just want to be clear....i tend to get confused easily so its easier to just clarify everything up front.

    Question1. You have some multiple testdata records helds in either a single file or multiple files (one record in each testdata file) on your laptop. Is that right?

    Question2. You have a single api endpoint which you want to send the content in these testdata files. Is that right?

    Question3. Youve been given a wsdl file to help you setup the required tests. Is that right?

    Question4. You mention a wsdl, so this is a SOAP request. Is that right?

    Question5. The content of your testdata defined records. Is it whole xml instances (which youve been told is the payload for you SOAP requests) or have you just got a list of attribute values in your testdata that has been mapped to xml tags within a predefined payload?

    Question6. What level of setup and automation is required? Do you want a single testcase to loop through your testdata (which requires groovyscript) or is it acceptable for individual testcases, 1 testcase for each testdata permutation defined?


    Cheers,

    Rich
    • Mis3's avatar
      Mis3
      Frequent Contributor

      Apology of being confusing.  I am sure I am not using the right terminologies.

       

      Question1. You have some multiple testdata records helds in either a single file or multiple files (one record in each testdata file) on your laptop. Is that right?

      [MIS3]

      Yes.  In my SoapUI, I have multiple API calls (XML scripts) to update tables in several external systems.    Each API has it own endpoint.  If there is a project which I have to update more than one external system, I would execute the XML scripts one after the other.  

      For now, I have a project which I have to send the same XML script to the same endpoint 1,000 times with only one variable (subscriber-ID).  I am hoping there is a way so SoapUI will read a external file and sends the XML request 1,000 times.

       

      Question2. You have a single api endpoint which you want to send the content in these testdata files. Is that right?
      [MIS3]  Yes, one single endpoint in this new project.


      Question3. Youve been given a wsdl file to help you setup the required tests. Is that right?

      [MIS3]  

      This is what I did.  I created a new project in SoapUI, then enter the wsdl.  SoapUI will then create all the API calls under this project.  I would see a lot of "Request 1" in each API.   I would modify the Request 1 for my purpose.

      All these calls (mostly XML but a few are in JSONS) are working.


      Question4.

      You mention a wsdl, so this is a SOAP request. Is that right?

      [MIS3]  I think so.   Please refer to my response of Question3 above.

      Question5. The content of your testdata defined records. Is it whole xml instances (which youve been told is the payload for you SOAP requests) or have you just got a list of attribute values in your testdata that has been mapped to xml tags within a predefined payload?

      [MIS3] 

      Not sure what is an instance.  If you are referring to the payload (XML script), they are all working.  I would just replace the variable (in this case, subscriber-ID) and click Send.  


      Question6. What level of setup and automation is required? Do you want a single testcase to loop through your testdata (which requires groovyscript) or is it acceptable for individual testcases, 1 testcase for each testdata permutation defined?

      [MIS3] 

      Yes, a single testcase to loop through my testdata.  

      If there are 5 records I have to update, I would execute the XML script 5 times.  However, this time I have to update 1000 records, so, I am hoping that there is a way (a loop) to do this more efficiently.

      I will research on Groovyscript.  Is there any online tutorial for this?

       

      • richie's avatar
        richie
        Community Hero
        Hey Mis3,

        Ok. So you have a single file with subscriberIds that need to be passed to a subscriberId element in the SOAPBody of your SOAP test step in a looping test to inject each request until all the subscriberId values have been used, right?

        If youre brand new to soapui and dont have any coding experience the following link is probably the easiest way of doing what you need i have found. Personally i always use csv's as the datafile rather than a spreadsheet as it adds extra complication.

        Anyway. Check out this link.

        http://roadtoautomation.blogspot.com/2013/08/road-to-data-driven-testing-in-soapui.html?m=1

        Youll need two test steps in your testcase. First one will be a groovyscript test step. Second teststep will the your SOAP test step.

        I'm typing this out on my phone so please forgive the lack of formatting. Taking the detail supplied in the linked webpage and the detail youve indicated, im guessing your code will need to look like the following:

        def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)

        def csvFilePath = "D:\\URL.csv"

        context.fileReader = new BufferedReader(new FileReader(csvFilePath))

        rowsData = context.fileReader.readLines()

        int rowsize = rowsData.size()

        for(int i =0; I < rowsize; i++)

        {

        rowdata = rowsData[i]
        String[] data = rowdata.split(",")
        log.info data[1]

        groovyUtils.setPropertyValue("SOAPTestStepName", "SubscriberId", data[0])

        testRunner.runTestStepByName( "SOAPTestStepName")
        }

        In your SOAP teststep where your subscriberId value should go, insert the value ${subscriberIdValue}, so the subscriberId element in your SOAPBody looks like:

        <SUBSCRIBERID>${subscriberIdValue}</SUBSCRIBERID>

        Ok. I think thats all you need to do. Follow those instructions and i think youre sorted.

        Cheers!

        Rich