Transferring values from the request to the response in SOAPUI

This is straightforward scripting done at the MockResponse level; the script uses properties of the mockRequest object to get hold of the incoming request, extracts the desired values via XPath and then writes the created result to a requestContext property

def temp="JavaVillage";
def groovyUtils=new com.eviware.soapui.support.GroovyUtils(context)
def xml=new XmlSlurper().parseText(mockRequest.requestContent)
xml.breadthFirst().each{
        def v=it.toString()
        if(it.name()=="name"){
                temp=it.text();
                log.info("============================================="+it.text());
        }
}
context.session=temp+' Munna'
mockOperation.setDefaultResponse("R1");

1. Created mock service as ContextResponse with script. Here will have single response, based on request will return response. From request will take name as a message will add with"Munna" string.

session creation in soapui

2. This is the response

Mock response using session in soapui

3. Start the server for contextService and execute request. Find the output below:

mock result using session in soapui