Forum Discussion

pandap's avatar
pandap
Contributor
11 years ago

[Resolved] Unable to save raw response and request xml file

Hi,

I need to save each raw request and response data into table, which is working fine when I run the functional test.

myRequestStep = testRunner.testCase.getTestStepByName('EIP_MeterReadWS')
def GetrequestData = new String(myRequestStep.testRequest.messageExchange.rawRequestData)
def GetresponseData = new String(myRequestStep.testRequest.messageExchange.rawResponseData)

But When I create a Fixed Load test for the project the raw response and request are not getting stored, is there a way I can store the raw request and response data into the table when I run load test.

Thanks,
Prashanth

10 Replies

  • Hi Manne,

    I created event handler for "TestRunListener.afterStep" and added following code to save the raw request/response data.

    filePath = "C:/SOAPUI/LOGS/TestResults/"
    fos = new FileOutputStream( filePath + testStepResult.testStep.label + ".txt", true )
    pw = new PrintWriter( fos )
    testStepResult.writeTo( pw )
    pw.close()
    fos.close()

    When I run the test case I get the request and response saved to the file but when I create a load test and run following message printed in the output file.

    Status: OK
    Time Taken: 5636
    Size: 600
    Timestamp: Wed Oct 16 13:55:34 EDT 2013
    TestStep: 3.EIP_MeterReadWS
    Result has been Discarded!

    ----------------- Properties ------------------------------

    ---------------- Request ---------------------------
    <discarded>

    ---------------- Response --------------------------
    - missing response / garbage collected -
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hello Prashanth,

    You need to define an event listener to achieve this (by the way, this is probably a better solution for your functional tests too). See this page for instructions:

    http://www.soapui.org/Scripting-Propert ... dlers.html

    If you want to do it for all your requests, you should use the RequestFilter.afterRequest event. If it's only for the load test requests, use the LoadTestRunListener.afterStep event.

    Best regards,
    Manne Fagerlind
  • Hi Manne,

    Thanks for the information, I will try and let you know if it works with event listner.


    Prashanth
  • Manne,

    Let me know if you need any more information or files, as per your previous mail I also tried adding following events:

    RequestFilter.afterRequest
    When I run the test case or load test there is no information logged in fact the log file is not created at all.

    LoadTestRunListener.afterStep
    Only when the load test is run the log files are created but the raw request and response are not saved below is the extract from the file
    Status: OK
    Time Taken: 4960
    Size: 600
    Timestamp: Wed Oct 16 14:29:33 EDT 2013
    TestStep: 3.EIP_MeterReadWS
    Result has been Discarded!

    ----------------- Properties ------------------------------

    ---------------- Request ---------------------------
    <discarded>

    ---------------- Response --------------------------
    - missing response / garbage collected -
    Status: OK
    Time Taken: 5511
    Size: 600
    Timestamp: Wed Oct 16 14:29:33 EDT 2013
    TestStep: 3.EIP_MeterReadWS
    Result has been Discarded!

    ----------------- Properties ------------------------------

    ---------------- Request ---------------------------
    <discarded>

    ---------------- Response --------------------------
    - missing response / garbage collected -
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi

    There are two options on the test case that you could check. Depending on these settings results could could discarded.

    • Discard OK Result should unchecked

    • Max results should be greater than zero


    Regards
    Joel Jonsson
  • Manne,

    I set the value 20 for Max Results and I am able to save the raw request and response to the file but only with Load test under event "LoadTestRunListener.afterStep".

    When I add the same code for the event "RequestFilter.afterRequest" and run the test case I am not able to save the raw request and response, Its not even creating the blank file so I suppose the event is not getting fired.

    Can you provide documentation of all the events with brief description of when they are fired.


    Thanks,
    Prashanth
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi!

    I'm glad you got it working with the LoadTestRunListener.

    You can not use the same code for the "RequestFilter.afterRequest" event since you do not have the same variables available. You can see the available variables in the top right corner of the editor.
    A (very) brief description on the events can be found at the end of the page that Manne provided before (http://www.soapui.org/Scripting-Propert ... dlers.html)

    Regards,
    Anders
    SmartBear Sweden
  • Thanks for the information, I now know which classes can be invoked in each event.

    Can you give the code to save raw request and response in RequestFilter.afterRequest.

    One more question can we continue with the execution of test suite with out waiting for completion of the request (1.e before we get the response).

    Thanks,
    Prashanth
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi Prashanth,

    Normally, we don't provide detailed help for Groovy scripting (it's not part of our SLA), but you can use request.getRequestContent() in the RequestFilter.afterRequest event to get the content of the request as a string. Here's a link to the API documentation for SoapUI, where you can find out more about what you can do.

    As for your second question - if you have multiple test cases in your test suite, you can set them to run in parallel. The button for doing this is in the same place as the Run/Abort buttons for the TestSuite. You cannot however skip ahead in a test case while waiting for the response of a previous step. Does that answer your question?

    Let us know if you have any more questions

    Regards,
    Arian
    SmartBear Sweden
  • That helped me save the raw response and request.

    Thanks for the help,

    Ticket is resolved.

    Prashanth