【发布时间】:2010-12-19 18:27:18
【问题描述】:
我正在尝试读取传入请求并根据soapUI 3.0 中的请求中的值设置模拟响应。为此,我使用以下 groovy 脚本。
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");
}
但是不行,抱怨mockRequest对象为null:
com.eviware.soapui.impl.wsdl.mock.DispatchException:使用脚本调度失败; java.lang.NullPointerException:无法在 null 对象上调用方法 getContentElement()
但我已经使用soapUI 2.0 版本的类似代码并且成功了。我该如何解决这个问题?
【问题讨论】:
标签: groovy mocking soapui groovy-console