Forum Discussion

stanjonsson's avatar
stanjonsson
New Contributor
12 years ago

Problems reading request content

I am trying to write a mock service that does some routing based on the body submitted in a POST request.
When I try doing the following:

mockRequest.requestContent

(which I saw used here: http://www.soapui.org/Service-Mocking/c ... vices.html)
in a dispatch script, the returned content is always null.
I also tried manually reading the request content from mockRequest.getHttpRequest().getInputStream(). That does work the first time around, but if I submit another request shortly afterwards the content read is empty. I tried closing all IO resources but to no avail.
The attached script shows the issue. Start the LoginMock and then run the SuccessLogin request. If it behaves as on my machine the first request should return '"authenticated": true', but subsequent requests return '"authenticated": false' (unless you wait 45+ seconds between requests).
I am running this on Windows 7 in SoapUI 5.0.0.

What is the recommended way to read content from a POST request, in a MockService?

3 Replies

  • I tried downloading SoapUI 5.12 Pro to see if this was an issue there as well.
    In SoapUI Pro mockRequest.requestContent does return a content value first time around (as can bee seen from the script log when running my attached script), but subsequent calls within 30 seconds all result in mockRequest.requestContent returning the empty string ("")
  • leonhardS's avatar
    leonhardS
    New Contributor
    I have the same problem. In the current SoapUI Maintenance the bug is fixed. You can use mockRequest.requestContent
    However there is a new bug with the http status in there. The status is always "200 OK" also I changed the response it into http status 404.

    I have enclosed the link:
    http://www.soapui.org/Downloads/soapui- ... uilds.html
  • I had the same problem, and I found that it is caused by the HTTP setting "Enable Mock HTTP Log" in the SoapUI preferences.

    If logging is turned on, then for two requests shortly after each other, in the second request mockRequest.requestContent contains an empty string.

    If logging is turned off, then for both requests, mockRequest.requestContent contains the expected value.

    I tried this with SoapUI 5.0.0 and SoapUI 5.0.0-m-SNAPSHOT that says "Build Date: 20140710-1533". Both on Windows 7.