Now the third way to pass session id from login response to addProduct request is quite simple.
For that in groovy script we do the following.
import com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext;
import com.eviware.soapui.support.XmlHolder;
log.info "In the groovy test step 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
//Then using the below command make project level property named session id and pass session id into it.
project.setPropertyValue('sessionid',sesionid);
Then we can go to our addProduct soap request and ask it to take session id from project level custom property by right clicking the space for session id and doing it.
Then we can use the below command to run the addProduct request from groovy request.
testRunner.testCase.getTestStepByName("addProducts").run(testRunner,context);
Our if we don’t want to run our soap request from this groovy script delete the above line and then we can keep just one groovy script in our test case and keep it above addProduct soapp request and go to test case level and click run so that first groovy script is run and then the addProduct soap request