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.
2. This is the response
3. Start the server for contextService and execute request. Find the output below: