cancel
Showing results for 
Search instead for 
Did you mean: 

New to SoapUI

Mis3
Occasional Contributor

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”. 

8 REPLIES 8
richie
Community Hero

Re: New to SoapUI

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
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Mis3
Occasional Contributor

Re: New to SoapUI

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
Community Hero

Re: New to SoapUI

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
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Mis3
Occasional Contributor

Re: New to SoapUI

Thanks, Ritchie.   This is GREAT HELP; I have something to start with!

 

I can see that the statement associates the 1st data field to SubscriberId:

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

 

How do you associate SubscriberId to this subscriberIdValue?

<SUBSCRIBERID>${subscriberIdValue}</SUBSCRIBERID>

 

Also, how about the type of property like Project level, Testsuite level, testcase level?  Like ${#TestSuite#SubscriberId}

 

 

richie
Community Hero

Re: New to SoapUI

Hry @Mis3,

Sorry i made a mistake...proving i really shouldnt be trying to do this on my phone!

Anyway. The script should work if you have a single file (csv) and a new subscriberId value comma separated one on each row.

Where the code says "groovyUtils.setPropertyValue("SOAPTestStepName", "SubscriberId", data[0])" change "SubscriberId" to "subscriberIdValue" so it reads as follows:

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

This will treat every single value in your csv file as a value associated with the "subscriberIdValue" property.

As i state in my previous message if you edit the value in the payload that corresponds to the "subscriberIdValue" property value....e.g.

<SUBSCRIBERID>${subscriberIdValue}</SUBSCRIBERID>

This links the values in your csv to the subscriberIdValue property to the </SUBSCRIBERID> element's value in your payload. The whole thing should work now.

Right, next thing. You ask about saving off the property to a different scope/level ....either project, testsuite, testcase, or in a properties step. Yes you can do this with some slight alterations to the setProperty line in the code. However, why would you want to do this in this case. What youre talking about is if you want to save the property for some other use. However, why would you want to for what you need? Also this is a looping testcase remember if you saved off the property values against project, testsuite, or testcase, these would be overwritten each loop of your testcase.

Ta

Rich

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Mis3
Occasional Contributor

Re: New to SoapUI

Thanks for your patient.  

I did watch some Youtube videos on Groovy script but I was lost when they talked about Class/Object.   As you can tell, I am not a Java developer.  

 

1.  The CSV file will be one subscriber per row.   I am not sure if the row will contain other fields (not needed in the teststep) but for sure they will be separated by comma and for sure the 1st field will be SubscriberID.

 

2.   I asked about saving off the property to a different scope/level because I thought the syntax calls for me to state the scope/level of this property.   It is simpler if I do not have to do this.   You are right, I just want to the script to read SubscriberId from a CSV file and sends the API call one by one.

 

3.  Maybe I should add log.info to write out the SubscriberID so I can ensure the looping script reads all the SubscriberID.

 

4.  Is there any way to write out the responses of the API calls?   I know that if the API call is successfully, the status will be 0.   If the SubscriberID does not exist, it will return status=306.

 

5.  Is it complicated to write out the log to a file in my laptop?

 

THANKS.

richie
Community Hero

Re: New to SoapUI

Hey @Mis3,

Hey, no need to thank me for patience. always happy to help. I wouldnt be able to help without the hours of people helping me when i first started with soapui a couple of years ago.

I wouldnt advise just watching any old testdriven/groovy script/soapui videos you find unless youve got more coding experience to successfully understand and evaluate what youre seeing.

Im not a coder at all. All my groovy experience is due to the help of other scripters on the site (@nmrao, @ChrisAdams, @msiadak, @HimamshuTayal, etc.), but im positive the script i gave you will work IF everything you mentioned in your previous posts is correct. If youre still having problems then theres other considerations we havent got nailed down yet or i havent been clear when ive been explaining something.

Point1 response: from what you said you only have one input field that needs to source a single subscriberId for each test. The subscriberId values should be comma separated....one per row

Point2 response: saving off property values against different scope levels is normal, however from what youve said, it isnt necessary as once youve set the property it immediately gets used (subscriberId is sourced from csv and passed to input payload), so no need to save the property value at a specific scope level.....typically you do this if you need to reuse the property value later on in your tests. In this case we're using the value immediately, so no need to worry about saving at different scope levels.

Point3 response: i find using log.info invaluable in most cases (typically i use it to make sure the variable has been assigned the value correctly) however i didnt think it necessary as we're using a single value and i can read the code so know what it doing

Point4 response: you can either use groovy to write out the responses, but easiest option is to use the "Dump File" attribute on your 'TestRequest Properties'. ( to find it, click on the SOAP teststep in your testcase to highlight it, then view the TestRequest Properties in the bottom left hand corner of your project 'Navigator'. This dump file option allows you to specify a path of where the SOAP teststeps response can be saved. I need to have a bit of a read on this however, i typically use readyapi ,not soapui and i use event handlers to write off my responses. This is pro functionality however, and not available in soapui, so i'd need to do a bit of reading to see if a looping testcase will append responses rather than overwrite the previous loop's response content.
HOWEVER, id suggest we can worry about saving your response content later once we get the rest of your script working.

Im guessing the script still isnt working correctly considering your latest questions, so could i ask for your next post you attach screenshots (dont embed!, i can never see embedded screenshots) to help me see whats going wrong?

If you could attach the following we can get everything sorted so we can move onto saving your responses.

Please attach the following:

1. csv file with suvscriberIds
2. Screenshot of your looping test case in the project navigator
3. Screenshot of the XML tab of your input for your SOAP teststep.
4. Screenshot of both RAW and XML response tabs of a successful request (status 0) and an unsuccessful request (status 306 where subscriberId does not exist)
5. Screenshot of your groovy script step contents so i can see what you have so far.

If you provide all of the above, we should be able to sort things straightaway.

By the way, if your concerned about security issues by sharing technical info, the only thing you need to obfuscate/hide is the "hostname/ip address" in the URL of your SOAP test steps. All other details would be no use to someone from a security perspective without the hostname/ip address, so as lomg as you hide/blank out that in your screenshots, youll be fine from a security perspective.

Cheers,

Rich
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Mis3
Occasional Contributor

Re: New to SoapUI

I have not created the looping script yet.   Frankly, I have to learn how and to enter the script.

I have attached a document containing the sample data file and a working XML request with successful and failed responses (errorCode=0 and errorCode=306).

 

1.  In the CSV file, since there is only one parameter per row, should I still have to put in a comma?

2.  Good I do not have to specify the level of the property.  True that this property would not be used anywhere else.   (BTW, the name of the property is MSISDN, not SubscriberID).

3.  Agreed.   With log.info, I can ensure that the script reads all the values in the CSV file.  

4.  I  have included the responses (XML and RAW) of the request in the document.  Not sure how to extract the errorCode to a log file.

 

Thanks.

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors