Second way of passing variables from one response to another request

Let us pass variables from a soap response(login test step in do Login test case ) to a soap request(add Products test step in addProduct test case) using groovy utils class.

Here we create a groovy script in the same test case as addProduct and add following code to it.

import com.eviware.soapui.support.GroovyUtils
import com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext;
import com.eviware.soapui.support.XmlHolder;

log.info "In the groovy test step  2 for AddProduct"
project = testRunner.testCase.testSuite.project;
loginStep =  project.testSuites["login"].testCases["dologin"].testSteps["doLogin"];
def logintestStepContext  =  new WsdlTestRunContext(loginStep);

loginStep.run(testRunner,logintestStepContext);
def response = logintestStepContext.expand('${doLogin#response}')
def xml  =  new  XmlHolder(response);
sessionid = xml.getNodeValue('//sessionid');
log.info "The session id is " + sessionid


def gUtils =new  GroovyUtils(context) 
def holder = gUtils.getXmlHolder('addProducts#request') //get Xml for addProducts request
 holder.setNodeValue('//sessionid',sessionid);//change the xml i.e put the given session id for session id node

holder.updateProperty();//set session id in request as well
//i.e when we run the above command the session id will change in our addProduct request as well
//So we see its easier to change the request using GroovyUtils.We simply use update Property.We
//dont have to use all that setPropertyValue that we used in first case.