Forum Discussion
M_McDonald
16 years agoSuper Contributor
I think you are on the right track; you can certainly change the content of the child datasource.
As far as using repeated elements I have used this sort of test structure:
The Contacts datasource would contain the repeating contact information. The Contacts script step would have code to aggregate the contacts into an XML fragment which is stored as a property in the Properties step.
which will put something like the following in the Properties step:
Then the request can use a property expansion to include the aggregated XML.
The Reset step would simply clear out the xmlFragment before the next loop through the Person datasource.
As far as using repeated elements I have used this sort of test structure:
Person DataSource
Contacts DataSource
Contacts Script (Groovy)
Contacts DataSource Loop
Properties Step
Request
Reset Script (Groovy)
Person DataSource Loop
The Contacts datasource would contain the repeating contact information. The Contacts script step would have code to aggregate the contacts into an XML fragment which is stored as a property in the Properties step.
def gu = new com.eviware.soapui.support.GroovyUtils( context )
def contactText = context.expand( '${Contacts DataSource#contactText}' )
def code = context.expand( '${Contacts DataSource#code}' )
def contactType = context.expand( '${Contacts DataSource#contactType}' )
def frag = context.expand('${Properties#xmlFragment}')
frag += """<Contacts><ContactText>${contactText}<ContactText>
<Code>${code}</Code>
<ContactType>${contactType}</ContactType>
</Contacts>
"""
gu.setPropertyValue('Properties', 'xmlFragment', "${frag}" )
which will put something like the following in the Properties step:
<Contacts><ContactText>Able<ContactText> <Code>1</Code> <ContactType>A</ContactType> </Contacts>
<Contacts> <ContactText>Baker<ContactText> <Code>2</Code> <ContactType>B</ContactType> </Contacts>
<Contacts> <ContactText>Charlie<ContactText> <Code>3</Code> <ContactType>C</ContactType> </Contacts>
<Contacts> <ContactText>Delta</ContactText> <Code>4</Code> <ContactType>D</ContactType> </Contacts>
Then the request can use a property expansion to include the aggregated XML.
...
<Person>
<Name>${Person DataSource#name}</Name>
<Surname>${Person DataSource#surname}</Surname>
${Properties#xmlFragment}
</Person>
...
The Reset step would simply clear out the xmlFragment before the next loop through the Person datasource.