Forum Discussion

randomnet's avatar
randomnet
New Contributor
12 years ago

Groovy script caches request.submit()

I have a groovy script for a mockservice which checks a request attribute and decides whether to respond with a mockResponse or forward the request to the server (from the soapUI MockService as proxy tutorial).
It works, but I see that the responses from the server are cached and I need to wait for sometime before I actually get anything to the server.


}else {
// Server response
def project = mockOperation.mockService.project
def request = project.interfaces["DeviceServiceBinding"].operations["update"].getRequestByName("Request 1")
request.requestContent = mockRequest.requestContent
request.submit( new com.eviware.soapui.impl.wsdl.WsdlSubmitContext( request ), false )
requestContext.responseMessage = request.responseContentAsXml
return "ServerResponse"
}


and the mock response "ServerResponse" is
${responseMessage}


How do I avoid request.submit(...) caching?

1 Reply

  • randomnet's avatar
    randomnet
    New Contributor
    Well, I solved the problem by creating a new request instead of using an existing one and waiting for the response.
    } else { 
    // Server response
    def request = mockOperation.getOperation().addNewRequest("ServerRequest")
    request.setRequestContent(mockRequest.requestContent)
    def submit = request.submit( new com.eviware.soapui.impl.wsdl.WsdlSubmitContext( request ), false )
    // wait for the response
    def response = submit.getResponse();
    requestContext.responseMessage = response.getContentAsString();
    return "ServerResponse"
    }