Forum Discussion

afrasso's avatar
11 years ago

Trouble Logging Request Content

I'm new at using SoapUI and attempting to use it as part of some automation testing. I've set up a mock REST service, which simply responds with a 200 - OK for any request.

I've added the following Groovy script to try and capture the request content:


try {
log.info mockRequest.getRequest().getReader().ready()
while ((line = mockRequest.getRequest().getReader().readLine()) != null)
log.info("line:" + line);
} catch (Exception e) {
log.error("exception:" + e)
}


The first time I send a request to the endpoint, I get what I expected:

Thu Aug 28 13:51:10 EDT 2014:INFO:true
Thu Aug 28 13:51:10 EDT 2014:INFO:line:asdasd

However, any subsequent requests sent to the mock service results in the call to mockRequest.getRequest().getReader().ready() not returning true.

I've tried using mockRequest.getRequestContent() as an alternative way to read the request, but that just returns null.

Any ideas?

Thanks.
  • droidlooms's avatar
    droidlooms
    New Contributor

    I am seeing the same problem with 5.0.0, have ever got any response to your question.

    • droidlooms's avatar
      droidlooms
      New Contributor

      Created a mock rest service which returns the response based on the content of request. So I created the script under the mock service script editor and trying to read the request line by line. But the line mockRequest.getRequest().getReader().ready() returns false, I have to wait for 8-10 mins before it clears off itself and return true. Its making me to wait for sometime before making another request. I also tried using mockRequest.getRequest().getReader().close() before returning but no use.

    • compumimo's avatar
      compumimo
      New Member

      I'm having the same problem with SoapUI 5.0.0 (Free) and REST mockservice scripting.

       

      1. This script returns null for the requestContent:

       

      def requestContent = mockRequest.getRequestContent()
      log.info "message content: " + requestContent

       

      --> Mon Mar 30 11:50:27 EEST 2015:INFO:message content: null

       

      2. This next scripts return the message content in the first time to the script log fine, but in the  second time it returns false, as said in  the previous comments. I need to restart the REST mockservice, then it works in the first again, but then again in second time it returns false, so something seems to be wrong with the scripts on SoapUI 5.0.0?

       

      try {
         log.info mockRequest.getRequest().getReader().ready()
         while ((line = mockRequest.getRequest().getReader().readLine()) != null)
            log.info("line:" + line);
      } catch (Exception e) {
         log.error("exception:" + e)
      }

       

      -->

      Mon Mar 30 11:53:01 EEST 2015:INFO:true
      Mon Mar 30 11:53:01 EEST 2015:INFO:line:<?xml version="1.0" encoding="UTF-8"?>
      Mon Mar 30 11:53:01 EEST 2015:INFO:line:<msg:deliveryInfoNotification xmlns:msg="urn:oma:xml:rest:netapi:messaging:1">
      Mon Mar 30 11:53:01 EEST 2015:INFO:line:<deliveryInfo>

       

      In second request it is not working anymore:

       

      --> Mon Mar 30 11:49:41 EEST 2015:INFO:false

      In error log I can see there error logs:

       

      Mon Mar 30 11:43:51 EEST 2015:ERROR:java.lang.IllegalStateException: READER
         java.lang.IllegalStateException: READER
             at org.mortbay.jetty.Request.getInputStream(Request.java:718)
             at com.eviware.soapui.monitor.JettyMockEngine$MockRequestLog.log(JettyMockEngine.java:797)
             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)
             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)

       

       

       

      • maddzy's avatar
        maddzy
        Occasional Contributor

        I'm having this exact same issue in 5.2.1

         

        Does anyone have a solution?

  • FozzyBear18's avatar
    FozzyBear18
    New Contributor

    I too am running into this very frustrating problem. Working soap UI 5.4 mock service deployed to Tomcat, handles the first request fine, truncates the 2nd and any others following. Restarting the service allows the first to work again only. With logging statements in the soapui OnRequest script section, I confirmed mockRequest.requestContent is getting cut off. I've adjusted tomcat server.xml HTTP connector sizing settings, using -1 values to remove limits. :  

     

    <Connector port="8888" protocol="HTTP/1.1"
    connectionTimeout="20000"
    maxPostSize="-1"
    maxSavePostSize="-1"
    redirectPort="8443" />

     

    I am out of ideas. 

  • FozzyBear18's avatar
    FozzyBear18
    New Contributor

    I too am running into this very frustrating problem. Working soap UI 5.4 mock service deployed to Tomcat, handles the first request fine, truncates the 2nd and any others following. Restarting the service allows the first to work again only. With logging statements in the soapui OnRequest script section, I confirmed mockRequest.requestContent is getting cut off. I've adjusted tomcat server.xml HTTP connector sizing settings, using -1 values to remove limits. :  

     

    <Connector port="8888" protocol="HTTP/1.1"
    connectionTimeout="20000"
    maxPostSize="-1"
    maxSavePostSize="-1"
    redirectPort="8443" />

     

    I am out of ideas.