I'm trying to read the incoming request & set the mock response depending on a value comming in the request in soapUI 3.0
. I use the following groovy script for this.
def typeElement = mockRequest.getContentElement().execQuery("//ProductType");
def records = new XmlParser().parseText(typeElement[0].xmlText())
if (records.text()=="15"){
mockOperation.setDefaultResponse("Response 2");
} else {
mockOperation.setDefaultResponse("Response 1");
}
But it does not work, complaining that mockRequest
object is null:
com.eviware.soapui.impl.wsdl.mock.DispatchException: Failed to dispatch using script; java.lang.NullPointerException: Cannot invoke method getContentElement() on null object
but I've used similar kind of code with soapUI 2.0
version and was successful. How can I fix this?