Forum Discussion

M_McDonald's avatar
M_McDonald
Super Contributor
14 years ago

[Resolved]IllegalStateException from OnRequest in MockSer...

I had been using a MockService to echo a requests output in multiple request steps so that I could group assertions into smaller chunks. Perhaps I just did not notice before, but I am getting an IllegalStateException following the execution of code in the OnRequest event like this:

mockRequest.httpRequest.method = "GET"
resp = mockRequest.requestContent
def writer = mockRequest.httpResponse.writer
writer.print(resp)
writer.close()


I know why this happens (soapUI is calling the Writer when I have already called it in my script) but I wonder if there is a way to prevent it from happening; I get the response I expect but exceptions are expensive.

10 Replies

  • Hi,

    ok... try ending your script with

    return new com.eviware.soapui.impl.wsdl.mock.WsdlMockResult( mockRequest )

    Does that make any difference?

    regards,

    /Ole
    SmartBear Stockholm
  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    Including your suggestion:


    mockRequest.httpRequest.method = "GET"
    resp = mockRequest.requestContent
    def writer = mockRequest.httpResponse.writer
    writer.print(resp)
    writer.close()
    return new com.eviware.soapui.impl.wsdl.mock.WsdlMockResult( mockRequest )
  • Hi,

    ok, please check that the "Enable Mock HTTP Log" option in the global HTTP Settings is turned off - does that help?

    regards,

    /Ole
    SmartBear Stockholm
  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    Yes, the exception is no longer being displayed... but is it actually no longer occurring, or just hidden?
  • Hi,

    it is no longer occurring - the logging feature triggers the exception if one uses the writer during request processing.

    regards,

    /Ole
    SmartBear Stockholm