Hi,
I am new to SoapUI and have just configured a very simple MockService. Is it possible to manipulate the response so that for a particular request the response's elements are dynamically built up?
Scenario 1:
Request:
<record>
<identifier>ID1</identifier>
</record>
Response:
<response>
<child1>child 1</child1>
</response>
Scenario 2:
Request:
<record>
<identifier>ID2</identifier>
</record>
Response:
<response>
<child2>child 2</child2>
</response>
It is for a simple test and I don't need it to do any more than the above. I am currently doing the following that yields the results I want but since I am completely new to this I am sure there are better alternatives:
Response:
<response>
${dynElement}
</response>
Groovy script:
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def holder = groovyUtils.getXmlHolder(mockRequest.requestContent)
def reqRef = String.valueOf(holder.getNodeValue("//identifier"))
def child1Text = "<child1>child 1</child1>"
def child2Text = "<child2>child 2</child2>"
if (reqRef == "ID1") {
context.setProperty("dynElement", child1Text)
} else if (reqRef == "ID2") {
context.setProperty("dynElement", "child2Text")
}