我试图在SoapUI 5.0中模拟REST服务。我在OnRequest选项卡中使用了这个groovy脚本:
com.eviware.soapui.impl.wsdl.mock.WsdlMockResult mockResult = new com.eviware.soapui.impl.wsdl.mock.WsdlMockResult(mockRequest)
def httpResponse = mockRequest.httpResponse
httpResponse.setContentType("application/xml;charset=utf-8")
httpResponse.writer << "<root><user>ABC</user></root>"
httpResponse.status = 200
return mockResult
收到此错误:
Could not find matching constructor for: com.eviware.soapui.impl.wsdl.mock.WsdlMockResult(com.eviware.soapui.impl.rest.mock.RestMockRequest)
出了什么问题? :(
答案 0 :(得分:1)
呀!我找到了SoapUI 5的解决方案!
def httpResponse = mockRequest.httpResponse
mockResponse.setResponseHttpStatus(202)
httpResponse.setContentType("application/json;charset=utf-8")
mockResponse.setResponseContent('{"a": 1}')
答案 1 :(得分:0)
WsdlMockResult()
构造函数将WsdlMockRequest
作为参数。
请参阅documentation。