Forum Discussion
There are a few ways, and you shouldn't need to resort to Groovy Script. Two of the simple built in methods are:
- Use the Point and Click Get Data functionality from within your SOAP request to reference the Data Source properties.
- Put a Property Transfer test step between your two test steps and configure appropriate to your needs to transfer your data.
- ario8 years agoNew Contributor
Hi,
Thank you for your reply, I think your solution will work if only the XML already had 2 nodes. Please correct me if I'm wrong?
Sorry for being not clear, so my question is how to create a dynamic nodes the XML based on the datasource[excel] records?
So, in the excel I've got:
person_name John Smith Linda Howard Joe Bloggs
My current SOAP UI XML is below:
<xml> <persons> <person> </person> </persons> </xml>
I wanted the end result to look like below:
<xml> <persons> <person>John Smith</person> <person>Linda Howard</person> <person>Joe Bloggs</person> </persons> </xml>
Then finally to trigger the 'updated' XML request
- Radford8 years agoSuper Contributor
OK so I think I know what you want, assuming that it's not always going to be three records (because if it was you could just pre-create the nodes in your request). I think you might need groovy script.
(As a side note, you shouldn't need to loop in groovy, the DataSource step can be paired with a DataSource Loop test step to take care of the looping, check out the pages on Data Driven Testing)
You can still use the point and click get data functionality from within a groovy script, so this takes care of getting data into your script. Are you wanting to get more that one record from your datasource per loop? If so check out this page.
You then need to get your XML from the SOAP request, manipulate the XML, I like to use the Groovy
XmlParser to do this. then update your SOAP request with the new details.
The pseudo code will look a bit like this:
import groovy.xml.* import groovy.util.XmlParser import com.eviware.soapui.support.GroovyUtils // Get SOAP request test string def request = context.expand( '${SOAP Request#Request#RootNode}' ) // Parse request string into Node object // NB: This is non-namespace-aware def parser = new XmlParser() def rootNode = parser.parseText(request) // Manipulate rootNode object here // Update SOAP request with new data. def groovyUtils = new GroovyUtils(context) groovyUtils.setPropertyValue('SOAP Request', 'Request', XmlUtil.serialize(rootNode))
As mentioned the above code is not XML namespace aware, if you need this check out the XmlParser JavaDoc (In fact this is worth looking at regardless)
Related Content
- 7 years ago
- 7 years ago
- 13 years ago
Recent Discussions
- 8 hours ago
- 5 days ago