Forum Discussion
Hi Vikram,
Ok, that sounds interesting. I don't know much about ALM, but hopefully we can sort something out.
So a common pattern of data-driven testing in SoapUI can be:
1. Read line of CSV data or potentially a soap request (using Groovy) in your case. You can do this in a Groovy TestStep. Say you have read the values in you can set them as properties on the context holder e.g.
context["intA"]=2
context["intB"]=3
2. Setup a SOAP Request TestStep and use the properties from the context holder to parameterise the SOAP request. You can esily insert the values using whats called property expansions (see http://www.soapui.org/scripting---properties/property-expansion.html) e.g.
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope">
<soap:Header/>
<soap:Body>
<tem:Add xmlns:tem="http://tempuri.org">
<tem:intA>${intA}</tem:intA>
<tem:intB>${intB}</tem:intB>
</tem:Add>
</soap:Body>
</soap:Envelope>
2a) You can also use the data values from the context to parameterise Assertions e.g. XPath Assertion (expected value) or Content or Script Assertions.
3. Use another Groovy TestStep (there is also a Conditional Goto TestStep) to loop back to 1 if there are more rows of test data.
Of course if you want to dump the SOAP request/response into a file, the thats easy enough to add with Groovy.
Does this sound at all like what you wanted? It just sounded like it might be easier to work with data values e.g. CSV rather than having to manipulate XML with XPaths..
If this is not really what you need, we can get back to the plan A and I'll have a go at adapting that Groovy script to use XPaths instead.
Cheers,
Rup
Hi Rupert,
I am also facing a similar problem but the difference is that I am not doing SOAPUI testing but I need to update the SOAPUI response tag values from an excel before forwarding that response to another system ,since my main application is developed in groovy ,I was thinking if this can be done in groovy only.
So my excel header are actually XPATHS and the corresponding rows below contain the value.
any help would be great.
- rupert_anderson8 years agoValued Contributor
Hi,
Ok, I am not sure I get exactly what you mean, please can you explain more? So you say you arent testing with SoapUI, but want to update tags in the response - are you calling some kind of service that returns XML and wanting to update the response based on values taken from an Excel spreadsheet?
Thanks,
Rup
- amitavban8 years agoNew Contributor
Hi Rupert,
Yeah ,so I have an inhouse built(java-groovy) application which generates a SOAP response and I have to feed that response to a proprietory software .But before sending the response to the software I need to update few tag values as per the Excel received from third party.
For now I have manually updated the third party Excel column headers with XPATHs of the XML so that I can update the XMLs as per the values in the corresponding row.
My main problem is reading the column header and passing its value in place of
Envelope.Body.CamCommand.CamAction.tCANOTIFICATIONS.pCASECIDUNDL
in the below code
String fileContents = new File(FilePath).text def xmlfromFile = new File(FilePath) def Envelope = new XmlSlurper().parseText(xmlfromFile.getText()) Envelope.Body.CamCommand.CamAction.tCANOTIFICATIONS.pCASECIDUNDL = "NewData123" XmlUtil xmlUtil = new XmlUtil() println xmlUtil.serialize(Envelope) xmlUtil.serialize(Envelope, new FileWriter(xmlfromFile))
Thanks,
Amitav
- VigneshSakkarai7 years agoNew Member
The below link is having an example, Hope this will help
https://github.com/Vignesh-Sakkarai/ParseAndUpdateXML/blob/master/MainXMLParser.groovy