Reputation: 32
I need to test a web service with header-item lines with reading values from csv.
<urn:Requisition_BudgetReqExportHeaderDetails_Item>
<!--Zero or more repetitions:-->
<urn:item>
<urn:CompanyCode>
<urn:UniqueName>?</urn:UniqueName>
</urn:CompanyCode>
<urn:ERPRequisitionID>?</urn:ERPRequisitionID>
<urn:HoldTillDate>?</urn:HoldTillDate>
<urn:IsServiceRequisition>?</urn:IsServiceRequisition>
<urn:Name>?</urn:Name>
</urn:item>
</urn:Requisition_BudgetReqExportHeaderDetails_Item>
I can read values from CSV file but this web service is complex and items might be 1 or more than 2.
How can I handle this web service request?
Upvotes: 0
Views: 1662
Reputation: 168002
You can use JSR223 PreProcessor like:
Put the code to generate the XML payload into "Script" area, an example one would look like:
def writer = new StringWriter()
def xml = new groovy.xml.MarkupBuilder(writer)
xml.records() {
car(name:'HSV Maloo', make:'Holden', year:2006) {
country('Australia')
record(type:'speed', 'Production Pickup Truck with speed of 271kph')
}
car(name:'Royale', make:'Bugatti', year:1931) {
country('France')
record(type:'price', 'Most Valuable Car at $15 million')
}
}
sampler.addNonEncodedArgument("", writer.toString(), "")
Amend it to match your requirement
References:
sampler
- a shorthand to HTTPSamplerProxy class, see the JavaDoc for all available methods and fieldsUpvotes: 1