Laslow
12 years agoNew Contributor
How to change value in request with Groovy (with xmlns)?
Hi,
I have an xml request, like this:
I must set the values of the request in Groovy. I do it like this, and n2.Value changes from 400000121 to 123456789, it works well:
How could I change dat:correlationId from abcdefgh_2 to xyz_2 in the Groovy script?
I have an xml request, like this:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header/>
<env:Body>
<ser:QueryBillingProfileList xmlns:ser="http://xmlns.ccc.com/ng/EnterpriseServices/Core/CustomerParty/V2/services/">
<ser:eiMessageContext>
<dat:timeLeft xmlns:dat="http://messaging.ei.xxx.net/datatypes">100000</dat:timeLeft>
<dat:correlationId xmlns:dat="http://messaging.ei.xxx.net/datatypes">abcdefgh_2</dat:correlationId>
</ser:eiMessageContext>
<ser:data>
<v2:QueryBillingProfileListEBM xmlns:v2="http://xmlns.oracle.com/EnterpriseObjects/Core/EBO/CustomerParty/V2">
<n1:EBMHeader xmlns:n1="http://xmlns.oracle.com/EnterpriseObjects/Core/Common/V2"/>
<v2:DataArea>
<v2:Query>
<v2:QueryCode>QueryBillingProfileListByID</v2:QueryCode>
<n2:QueryCriteria xmlns:n2="http://xmlns.oracle.com/EnterpriseObjects/Core/Common/V2">
<n2:QueryExpression logicalOperatorCode="AND">
<n2:ValueExpression queryOperatorCode="EQUALS">
<n2:ElementPath>/BillingProfile/Identification/BusinessComponentID</n2:ElementPath>
<n2:Value>400000121</n2:Value>
</n2:ValueExpression>
</n2:QueryExpression>
</n2:QueryCriteria>
</v2:Query>
</v2:DataArea>
</v2:QueryBillingProfileListEBM>
</ser:data>
</ser:QueryBillingProfileList>
</env:Body>
</env:Envelope>
I must set the values of the request in Groovy. I do it like this, and n2.Value changes from 400000121 to 123456789, it works well:
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = groovyUtils.getXmlHolder( "billingProfile#Request" )
holder["//n2:Value"] = "123456789"
holder.updateProperty()
context.requestContent = holder.xml
How could I change dat:correlationId from abcdefgh_2 to xyz_2 in the Groovy script?