Consider the following XML
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:raad="http://raadpleegles.aanboddienst-01_00.davinci.ov.vlaanderen.be">
<soapenv:Header/>
<soapenv:Body>
<raad:RaadpleegLes>
<LesCreate>
<ObjectID>2d4e672c-8ebb-4a6d-9ee6-12eabf4b446a:14c47413430</ObjectID>
<ConcurrencyToken>cdb93192-c8e9-4f85-9e52-54f2482b99c9:14c47413430</ConcurrencyToken>
</LesCreate>
<LesDelete>
<ObjectID>5d4e672c-8ebb-4a6d-9ee6-12eabf4b446a:14c47413430</ObjectID>
<ConcurrencyToken>cdb93192-c8e9-4f85-9e52-54f2482b99c9:14c47413430</ConcurrencyToken>
</LesDelete>
<Les>
<ObjectID>hd4e672c-8ebb-4a6d-9ee6-12eabf4b446a:14c47413430</ObjectID>
<ConcurrencyToken>cdb93192-c8e9-4f85-9e52-54f2482b99c9:14c47413430</ConcurrencyToken>
</Les>
<DONTCHANGE>
<ObjectID>hd4e672c-8ebb-4a6d-9ee6-12eabf4b446a:14c47413430</ObjectID>
<ConcurrencyToken>cdb93192-c8e9-4f85-9e52-54f2482b99c9:14c47413430</ConcurrencyToken>
</DONTCHANGE>
</raad:RaadpleegLes>
</soapenv:Body>
</soapenv:Envelope>
Several nodes name name starting with the string "Les". In those nodes Id like to change the value of their child node named "ObjectID". I can not do that for everything else like "DONTTOUCH". To substitute this script will work fine
import com.eviware.soapui.impl.wsdl.teststeps.*
import com.eviware.soapui.support.XmlHolder
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def steps = testRunner.testCase.getTestStepsOfType( WsdlTestRequestStep.class )
def project = testRunner.testCase.testSuite.project
for (step in steps) {
log.info step.name// + step.getLabel()
def holder1 = groovyUtils.getXmlHolder( step.testRequest.requestContent )
assert project.getPropertyValue("objectid") != null, "no objectid set"
holder1["//Les/ObjectID"]=project.getPropertyValue("objectid")
holder1["//LesCreate/ObjectID"]=project.getPropertyValue("objectid")
holder1["//LesDelete/ObjectID"]=project.getPropertyValue("objectid")
holder1.updateProperty()
step.testRequest.setRequestContent (holder1.getXml());
}
In the example I included only 3 different names for the nodes to replace (Les, LesCreate, LesDelete). Now imagine there are not 3 but hundreds of possibilities, then how should one go about this?
Providing an expression the equivalent of //Les*/ObjectID would be my first attempt but I cant see how to include that in the supplied groovy script.