cancel
Showing results for 
Search instead for 
Did you mean: 

Data Import from CSV or XML

SOLVED
Occasional Contributor

Data Import from CSV or XML

SOAP Newbie here.

 

Successfully created my first SOAP Project and request to create a record.

 

Now how can I do a mass import by getting the data from a csv/xml source file and then loop through my soap request?

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
Community Hero

Re: Data Import from CSV or XML

Hi @HEATConsultant

 

There's lots of different ways to do this - some of other lads on this site will provide alternatives - but the way I would do this is as follows:

 

If it's SOAP - did you create the project from a .wsdl file?  Cos that'll make this easier. 

 

I save the test data files to an appropriate directory (call it c:\testdata\test1\whatevs.xml)

I use a datasource (directory type)

SOAP POST request (the body of the request will populated with the testdata file)

Datasource loop

 

so my test case's test step hierarchy is as follows:

 

Datasource 
SOAP POST request 
Datasource Loop

OK - low level instructions to do the above are as follows:

 

Create the test suite object within your project

Create the test case objecct within your project

Right click and click on the 'Add Step' - this launches the 'Add Step' form, click on 'OK' to accept the Datasource step name.

A 'Generate Properties' dialogue launches, I always click 'No' at this point and I come back to this later.

On the 'Datasource' step, click on the 'Data Source' dropdown and select 'Directory'

Click on the 'Select directory' 'Browse' button to navigate to the directory in which your testdata files reside (e.g.c:\testdata\test1)

In the 'Filename Filter' field, input '*.xml'

Within the 'Properties' frame on the Datasource step, click on the green plus ('Add Property') - an 'Add Property' form launches - input 'fileContents'.

Click on the green right arrow, which launches a form entitled 'Test data source' - the field auto populates with '10' - you need to alter this to '1'

Within the test case hierarchy, right click on the 'Datasource' object within the test case in the 'Navigator' frame.

Right click and click on the 'Insert Step' and select 'SOAP Request' - 'Add Step' form launches, click on 'OK' to accept the name for the SOAP test step, this launches a 'New Request' form to select the SOAP request - click on 'OK', this launches an 'Add Request to TestCase' form - click on 'OK' button - this adds the SOAP request to the test case.

Within your test case hierarchy, highlight the SOAP request test step, and within your 'Request' frame, you have 4 vertical tabs (Form, Outline, Raw, XML).

Click on the 'Outline' tab, identify the SOAPBody tag (which equates to the operation name tag in your .wsdl) - the SOAPBody tag is the tag the should contain your .xml payload

Right click and select 'Get Data' - this launches a 'Get Data' form which is split vertically into 4 columns (Test Suite, Test Case, Test Step, Properties)

Click on the 'Datasource' in the 'Test Step' column which auto populates the 'Properties' column with the 'fileContents'.

Click on the 'fileContents' within the 'Properties' column and click on the 'Add' button to accept the changes and close the 'Get Data' form.

 

Within the test case hierarchy, right click on the 'SOAP Request' object within the test case in the 'Navigator' frame.

Right click and click on the 'Insert Step' and select 'Datasource Loop' - 'Insert Step' form launches, click on 'OK' to accept the name for the Datasource Loop test step.

Ensure the test step hierarchy is as I specify above (Datasource, then SOAP Request, then Datasource Loop)

Double click on the 'Datasource Loop' object to launch the 'Configure Datasource Loop' form.

Click on the 'Target Step' dropdown, select the 'SOAP Request' step and click on 'OK' to accept the changes and close the form.

 

 

That's it - you should be good to go - this test case will execute once thhrough all the .xml files saved in the directory specified.  Don't forget - you'll need to specify the appropriate authorisation on the SOAP Request step before the SOAP request will POST successfully.

 

Hope this helps,

 

Cheers,

 

richie

 

 

 

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

View solution in original post

5 REPLIES 5
Community Hero

Re: Data Import from CSV or XML

Hi @HEATConsultant

 

There's lots of different ways to do this - some of other lads on this site will provide alternatives - but the way I would do this is as follows:

 

If it's SOAP - did you create the project from a .wsdl file?  Cos that'll make this easier. 

 

I save the test data files to an appropriate directory (call it c:\testdata\test1\whatevs.xml)

I use a datasource (directory type)

SOAP POST request (the body of the request will populated with the testdata file)

Datasource loop

 

so my test case's test step hierarchy is as follows:

 

Datasource 
SOAP POST request 
Datasource Loop

OK - low level instructions to do the above are as follows:

 

Create the test suite object within your project

Create the test case objecct within your project

Right click and click on the 'Add Step' - this launches the 'Add Step' form, click on 'OK' to accept the Datasource step name.

A 'Generate Properties' dialogue launches, I always click 'No' at this point and I come back to this later.

On the 'Datasource' step, click on the 'Data Source' dropdown and select 'Directory'

Click on the 'Select directory' 'Browse' button to navigate to the directory in which your testdata files reside (e.g.c:\testdata\test1)

In the 'Filename Filter' field, input '*.xml'

Within the 'Properties' frame on the Datasource step, click on the green plus ('Add Property') - an 'Add Property' form launches - input 'fileContents'.

Click on the green right arrow, which launches a form entitled 'Test data source' - the field auto populates with '10' - you need to alter this to '1'

Within the test case hierarchy, right click on the 'Datasource' object within the test case in the 'Navigator' frame.

Right click and click on the 'Insert Step' and select 'SOAP Request' - 'Add Step' form launches, click on 'OK' to accept the name for the SOAP test step, this launches a 'New Request' form to select the SOAP request - click on 'OK', this launches an 'Add Request to TestCase' form - click on 'OK' button - this adds the SOAP request to the test case.

Within your test case hierarchy, highlight the SOAP request test step, and within your 'Request' frame, you have 4 vertical tabs (Form, Outline, Raw, XML).

Click on the 'Outline' tab, identify the SOAPBody tag (which equates to the operation name tag in your .wsdl) - the SOAPBody tag is the tag the should contain your .xml payload

Right click and select 'Get Data' - this launches a 'Get Data' form which is split vertically into 4 columns (Test Suite, Test Case, Test Step, Properties)

Click on the 'Datasource' in the 'Test Step' column which auto populates the 'Properties' column with the 'fileContents'.

Click on the 'fileContents' within the 'Properties' column and click on the 'Add' button to accept the changes and close the 'Get Data' form.

 

Within the test case hierarchy, right click on the 'SOAP Request' object within the test case in the 'Navigator' frame.

Right click and click on the 'Insert Step' and select 'Datasource Loop' - 'Insert Step' form launches, click on 'OK' to accept the name for the Datasource Loop test step.

Ensure the test step hierarchy is as I specify above (Datasource, then SOAP Request, then Datasource Loop)

Double click on the 'Datasource Loop' object to launch the 'Configure Datasource Loop' form.

Click on the 'Target Step' dropdown, select the 'SOAP Request' step and click on 'OK' to accept the changes and close the form.

 

 

That's it - you should be good to go - this test case will execute once thhrough all the .xml files saved in the directory specified.  Don't forget - you'll need to specify the appropriate authorisation on the SOAP Request step before the SOAP request will POST successfully.

 

Hope this helps,

 

Cheers,

 

richie

 

 

 

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

View solution in original post

Occasional Contributor

Re: Data Import from CSV or XML

Thanks @richie I will give that a try. Can this be done with SOAPUI as well?

Frequent Contributor

Re: Data Import from CSV or XML

Hi HEATConsultant,

 

ReadyAPI provided various data source to import. I think you'd better to try each one and try to know about which one is suitable for you. As for you mentioned csv/xml, Of course, you would take advantage of them to import massive data and maintain them in external data source. csv is easy to process with comma, and xml process depends on your data structure. You can search from community to find some useful solutions if you needs. and some guys who have provided some good approaches, for example:

https://community.smartbear.com/t5/SoapUI-Pro/Sharing-is-caring-how-to-modify-xml-files-using-ReadyA...

 

 

Occasional Contributor

Re: Data Import from CSV or XML

Thanks Richie. that worked pretty well. A few snags along the way but got it working.  That interface sure isn't userfriendly or all to intuitive so kudos to you for figuring it out!

Community Hero

Re: Data Import from CSV or XML

Hey man....i only know this stuff due to the help from all the other people who participate on the forum....I wouldnt know how to do anything without all their help!
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
New Here?
Join us and watch the welcome video:
Announcements