Forum Discussion
Yes, 3 different XPath of same request.
No we never get all 3 values and so we need not worry. We get any one value among 3 each time.
So we need to check which one is populated, check if its variable.xml is present and then load.
I tried for 2 variables, but did not work.
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def groovyUtils1 = new com.eviware.soapui.support.GroovyUtils(context)
def holder = groovyUtils.getXmlHolder(mockRequest.requestContent)
def holder1 = groovyUtils1.getXmlHolder(mockRequest.requestContent)
def soNumber = holder.getNodeValue("//*:BillAccountPackageReadRequest/*:ContractSolutionNumber")
def hsonum = holder1.getNodeValue("//*:BillAccountPackageReadRequest/*:HierarchyOnlySolutionNumber")
def file = new File (groovyUtils.projectPath+"/MOCK/SOL/${soNumber}.xml")
def hsolfile = new File (groovyUtils1.projectPath+"/MOCK/HSOL/${hsonum}.xml")
def fileToLoad = 'soapFault'
if (file.exists()) {
fileToLoad = soNumber
context.content = groovy.xml.XmlUtil.serialize(new XmlParser().parse(groovyUtils.projectPath+"/MOCK/SOL/${fileToLoad}.xml"))
}
else if (hsolfile.exists()) {
fileToLoad = hsonum
context.content = groovy.xml.XmlUtil.serialize(new XmlParser().parse(groovyUtils1.projectPath+"/MOCK/HSOL/${hsonum}.xml"))
}
- nmrao10 years agoCommunity HeroYou can't say it did not work because script is not done in that way.
- Apoorva610 years agoFrequent Contributor
Hi Rao,
It did not work as per my expectation. You mentioned to use of 3 different variables and try. Is that the same way which I tried ? I am poor in groovy. :(