Forum Discussion
- omatzuraSuper ContributorHi,
there is no really easy way to do this currently; you will need to create a groovy script that manually builds the entire XML block by calling the next( testRunner, context ) method of the DataSource step to get the next row, something like
def xml = ...
def dataSource = testRunner.testCase.testSteps["DataSource"]
while( dataSource.next() )
{
xml += .. add to xml block..
}
context.blockOfXml = xml
and then use this variable with
${blockOfXml}
in your request..
Hope this helps!
regards,
/Ole
eviware.com - Mike_MNew ContributorThanks for the reply.
When I try 'dataSource.next' however I get the following:
groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.teststeps.WsdlDataSourceTestStep.next() is applicable for argument types: () values: {}
Do I need to cast dataSource to a different type? - omatzuraSuper ContributorHi!
sorry, my mistake.. the call should be
next( testRunner, context )
sorry, hope this helps!
regards,
/Ole
eviware.com - Mike_MNew ContributorThanks again.
I ended up turning the rows of data into XML in a Groovy step, but I assigned it to a property, then used property expansion to place the relevant data in the request (see below.)
What I should do is read the list of properties from the DataSource and build the XML generically.
Groovy script:
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def dataSource = testRunner.testCase.testSteps['DataSource']
def xml = ''
while( dataSource.next( testRunner, context ) )
{
xml += '' '
xml += '' + groovyUtils.expand('${DataSource#OrderID}') + ' '
xml += '' + groovyUtils.expand('${DataSource#OrderName}') + ' '
xml += '
}
xml += ''
groovyUtils.setPropertyValue("Properties","xml", xml)
Request fragment:
${Properties#xml#//dataRow[1]/OrderID/text()}
${Properties#xml#//dataRow[1]/Name/text()}
${Properties#xml#//dataRow[2]/OrderID/text()}
${Properties#xml#//dataRow[2]/Name/text()}
- omatzuraSuper ContributorGreat!
Thanks for sharing your solution, this is not an unusual setup and I'm sure others will be able to use this..
regards,
/Ole
eviware.com
Related Content
- 13 years ago
- 4 years ago
- 2 years ago
- 4 years ago
Recent Discussions
- 15 years ago