Showing posts with label getXmlHolder. Show all posts
Showing posts with label getXmlHolder. Show all posts

Sunday, July 14, 2013

Update SoapUI Request with groovy or Property Transfer using groovy in SOAP UI

//Update SoapUI Request with groovy or Property Transfer using groovy in SOAP UI
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )

// get XmlHolder for request message def

ReqHolder = groovyUtils.getXmlHolder( "CelsiusToFahrenheit#Request" )

ReqHolder1 = groovyUtils.getXmlHolder( "FahrenheitToCelsius#Request" )

// Pass value to request node
ReqHolder["//tem:Celsius"] = "100"

// write updated request back to teststep
ReqHolder.updateProperty()

// Run the Request
testRunner.runTestStepByName("CelsiusToFahrenheit")

// Get the response value in a variable
def response = context.expand( '${CelsiusToFahrenheit#Response#declare namespace ns1=\'http://tempuri.org/\'; //ns1:CelsiusToFahrenheitResponse[1]/ns1:CelsiusToFahrenheitResult[1]}' )
log.info(response)


// Pass the new value to another request
ReqHolder1["//tem:Fahrenheit"] = response
ReqHolder1.updateProperty()

// run the test request
testRunner.runTestStepByName("FahrenheitToCelsius")

def response1 = context.expand( '${FahrenheitToCelsius#Response#declare namespace ns1=\'http://tempuri.org/\'; //ns1:FahrenheitToCelsiusResponse[1]/ns1:FahrenheitToCelsiusResult[1]}' )
log.info(response1)