Hi Nadia,
I refer to a sample web service to show what you talked. I don't know why I cannot attach img, so have to use text to illustrate here:
Example:
Endpoint:
http://www.webservicex.net/uszip.asmx?wsdl(Not sure if you can access this web service)
Test case consist of 2 steps:
step1: GetInfoByCity - Request 1
step2: Groovy Script - Change Response
Request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.webserviceX.NET">
<soapenv:Header/>
<soapenv:Body>
<web:GetInfoByCity>
<!--Optional:-->
<web:USCity>Houston</web:USCity>
</web:GetInfoByCity>
</soapenv:Body>
</soapenv:Envelope>
Response:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetInfoByCityResponse xmlns="http://www.webserviceX.NET">
<GetInfoByCityResult>
<NewDataSet xmlns="">
<Table>
<CITY>Houston</CITY>
<STATE>AK</STATE>
<ZIP>99694</ZIP>
<AREA_CODE>907</AREA_CODE>
<TIME_ZONE>K</TIME_ZONE>
</Table>
</NewDataSet>
</GetInfoByCityResult>
</GetInfoByCityResponse>
</soap:Body>
</soap:Envelope>
Scripts:
def groovyUtil = new com.eviware.soapui.support.GroovyUtils(context)
def xmlHolder = groovyUtil.getXmlHolder('GetInfoByCity - Request 1#Response')
xmlHolder.namespaces["ns1"] = "http://www.webserviceX.NET"
def city = xmlHolder.getNodeValue("//ns1:GetInfoByCityResult/NewDataSet/Table/CITY")
if (city != null){
if (city == "Houston")
xmlHolder.setNodeValue("//ns1:GetInfoByCityResult/NewDataSet/Table/CITY",0)
else
xmlHolder.setNodeValue("//ns1:GetInfoByCityResult/NewDataSet/Table/CITY",1)
log.info xmlHolder.getNodeValue("//ns1:GetInfoByCityResult/NewDataSet/Table/CITY")
}
Output:
0
Thanks,
Aaron