Friday, July 15, 2011

Groovy 9 - capturing RawRequest & Response

Few months back i was struggling to capture the Raw Request data from the test step and to store it (together with response) into a file. Now you might be wondering why to struggle so much if the test step request data can be simply accessed using :

Well above script snippets will fetch the request data from the mentioned/selected test step. However, if your test is parametrized then this (request data) will also appear as in same way as it appears in request window [i.e., not with actual parameter values].
Since, it is a parametrized request the original values of parameters can be found in the Raw tab of the teststep request window. This concept can be compared to "PreProcessors in C" or "Inline function of C++" where the actual values of parameter will be replaced before compiling the program. Here also, before sending out the request data (or say encapsulating it in SOAP envelope) to the server the parameter values will be replaced with each parameter calls in the test request.

If raw request data not used, then while performing the comparison of the different request & response data after final run, it would be difficult for us to trace what parameter value was passed during teststep run.
To overcome such issues, soapUI team also exposed couple of methods which can be used to extract the RawRequest / RawResponse data and so on. Shared below is one of the ways to get the raw request data :



  1. def tr = testRunner.testCase.getTestStepByName(serviceName) tr.getHttpRequest().getResponse().getURL()

  2. how to redirect response of the script into a file

  3. This comment has been removed by the author.

  4. hi,we provide online training & video tutorial for soapui
    for free videos refer

  5. Really great post, Thank you for sharing this knowledge. Excellently written article, if only all bloggers offered the same level of content as you, the internet would be a much better place Automate a business with technology. Please keep it up. Keep posting.
    Best regards