Could not find matching constructor for: WsdlMockResult(RestMockRequest)
I have a SOAP UI project that is built to provide mock response JSON to a request JSON.
Attached are 2 files
1. Groovy script used in the MockService to interpret the request and construct a dynamic JSON response.
2. Error log from SOAP UI
I have been able to test the JSON responses being sent to
1. My Mock Requests from within SOAP UI
2. By invoking SOAPUI project War file deployed in my tomcat locally.
However what I have noticed is that when we now try to hit the same URLs via our application code (Java code), it is failing.
Upon checking the error logs we noticed that the following error was appearing
- Mon Aug 27 14:33:01 AEST 2018:ERROR:com.eviware.soapui.impl.wsdl.mock.DispatchException: com.eviware.soapui.impl.wsdl.mock.DispatchException: Failed to dispatch using script; groovy.lang.GroovyRuntimeException: Could not find matching constructor for: com.eviware.soapui.impl.wsdl.mock.WsdlMockResult(com.eviware.soapui.impl.rest.mock.RestMockRequest)
- Mon Aug 27 14:33:01 AEST 2018:ERROR:got an exception while dispatching - returning a default 500 response
For some reason the responses are being received when
SOAPUI Mock Request --> SOAP UI Mock Service
SOAP UI Mock Request --> SOAP UI WAR deployed in Tomcat
It fails when the same Tomcat URL (http://localhost:8080/webservicemocks/dafStubs)
OR
SOAPUI Mock service URL (http://localhost:9080/dafStubs)
is invoked via Java code.
I have also attached my whole soap UI project XML here for reference.
Can someone point me in the right direction as to why I am seeing this error?
Thanks,
Ram
I implemented the 'Create User' request like this:
import groovy.json.JsonSlurper import groovy.json.JsonOutput import com.eviware.soapui.impl.rest.mock.RestMockResult Map responseObject = [:] switch (mockRequest.path) { case context.getMockService().path + '/admin/user': if (mockRequest.method.toString() == 'POST') { responseObject = createUser() } else if (mockRequest.method.toString() == 'PUT') { // etc } else { // etc } break case context.getMockService().path + '/admin/user/delete': //etc break default: break } mockRequest.httpResponse.setHeader ('Content-Type', 'application/json') mockRequest.httpResponse.getWriter() << JsonOutput.toJson(responseObject) return new RestMockResult(mockRequest) // Responses public Map createUser() { Map requestObject = new JsonSlurper().parseText(mockRequest.requestContent) return [ status: [ code: "DA-200", message: "Success", logMessage: "Success", logMessageAttributes: null ], createUserResult: requestObject.operationDetails ] }