Forum Discussion

PeteB's avatar
10 years ago

Test Case Mock Response differs from Mock Service

I'm trying to capture a request from our application in a test case using a SOAP Mock Response as part of an evaluation of SoapUI for our organization. The basic test currently consists of a test request (which handles the response fine) and a mock response to capture a request made to our clients web service (which is where I am having issues).

If I set up a Mock Service outside of the test case the message generated as a result of the test request is caught correctly and an appropriate response sent (in this case the second message sent as the first is handled by the test request step itself). However, when I try to recreate the Mock Response test step I see the following error in the SoapUI error log:


2014-12-15 12:25:49,784 ERROR [errorlog] com.eviware.soapui.impl.wsdl.mock.DispatchException: java.lang.NumberFormatException: null
com.eviware.soapui.impl.wsdl.mock.DispatchException: java.lang.NumberFormatException: null
at com.eviware.soapui.impl.support.AbstractMockResponse.execute(AbstractMockResponse.java:284)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockOperation.dispatchRequest(WsdlMockOperation.java:227)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockDispatcher.dispatchPostRequest(WsdlMockDispatcher.java:256)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockDispatcher.dispatchRequest(WsdlMockDispatcher.java:122)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockRunner.dispatchRequest(WsdlMockRunner.java:156)
at com.eviware.soapui.monitor.JettyMockEngine$ServerHandler.handle(JettyMockEngine.java:716)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.valueOf(Unknown Source)
at com.eviware.soapui.impl.support.AbstractMockResponse.getResponseHttpStatus(AbstractMockResponse.java:147)
at com.eviware.soapui.impl.support.AbstractMockResponse.writeResponse(AbstractMockResponse.java:337)
at com.eviware.soapui.impl.support.AbstractMockResponse.execute(AbstractMockResponse.java:272)
... 17 more
2014-12-15 12:25:49,787 ERROR [errorlog] java.lang.IllegalStateException: WRITER
java.lang.IllegalStateException: WRITER
at org.mortbay.jetty.Response.getOutputStream(Response.java:594)
at com.eviware.soapui.monitor.JettyMockEngine$MockRequestLog.log(JettyMockEngine.java:820)
at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:51)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)


I know that the request is valid as I have been able to capture it via the mock service (I've even added the mock response to the test case through the right-click menu available in the mock service), but when I reach the mock response in the test case it hangs and I just get a HTTP 500 error. At this point I can view the WSDL in a browser (as the mock response is still awaiting a request), so I can see it is using the correct WSDL (i.e. the same as was used for the mock service).

From the error it looks as though it is failing when it tries to read a HTTP status from the response (which does not occur when running the same request as part of a Mock Service)?

Just wondering if anyone else has had any similar issues when adding a known, working mock response from a mock service to a test case?

1 Reply

  • Thorsten's avatar
    Thorsten
    New Contributor

    Experienced the same issue. To solve this set the http status (to whatever is needed 200, 202, ...) for the response. This can be achieved by opening the editor for the SOAP Mock Response step and add in the Script tab the following script call:

     

    mockResponse.setResponseHttpStatus(200)

     

     

    soap_mock_response.jpg