Forum Discussion

debadatta's avatar
13 years ago

Finding soap request,response xml and specifix data values values

I have run a test case having  test request and one groovy step as well. It's a temperture conversion web service.

SOAP - Request



<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://webservices.daehosting.com/temperature">

   <soapenv:Header/>

   <soapenv:Body>

      <tem:CelciusToFahrenheit>

         <tem:nCelcius>80</tem:nCelcius>

      </tem:CelciusToFahrenheit>

   </soapenv:Body>

</soapenv:Envelope>



SOAP-Response

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

   <soap:Body>

      <m:CelciusToFahrenheitResponse xmlns:m="http://webservices.daehosting.com/temperature">

         <m:CelciusToFahrenheitResult>176</m:CelciusToFahrenheitResult>

      </m:CelciusToFahrenheitResponse>

   </soap:Body>

</soap:Envelope>





Groovy Code :

//Approach -1

def request=testRunner.testCase.getTestStepByName("CelToFah")

def responseData=request.getProperty("Response")

log.info(responseData) // successfully getting the response xml , but how to get the data value.

//Approach -2

def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )


def holder=groovyUtils.getXmlHolder("CelToFah#Response")

log.info(holder) //successfully getting the object

log.info(holder.getNodeValue("//m:CelciusToFahrenheitResponse/m:CelciusToFahrenheitResult") // not getting the value



//Approach -3

using messageExchange // all the time giving script error saying

 

def requsetHolder = groovyUtils.getXmlHolder( messageExchange.requestContent ) // not working at all