Forum Discussion

Donovan's avatar
Donovan
Occasional Contributor
11 years ago

Groovy Script Save Raw Request

Hello Bears,

I have googled and googled and still can't figure this issue out. I'm UNABLE to save the "raw request" from my testSteps.

This code works correctly.

//Define the object for the collection of requests in the soapUI test case
def soapuiRequests = testRunner.testCase.getTestStepsOfType(com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep )

//Groovy Script to loop through each requests in the test case.
soapuiRequests.each
{
//Creating file name using current date and time
Date startTime = new Date();
def cur_Time = startTime.getMonth() + "_" + startTime.getDate();
cur_Time = cur_Time + "_" + startTime.getHours() + startTime.getMinutes() +startTime.getSeconds()
def fileName = it.name + "_" + cur_Time

def inputFileRequest = new File("C:/Users/mtdonovan/Documents/Amc/MobilityCrew 1.2/SoapUI/Results/"+ "Request_" + fileName+".txt")
def inputFileResponse = new File("C:/Users/mtdonovan/Documents/Amc/MobilityCrew 1.2/SoapUI/Results/"+ "Response_" + fileName+".txt")
//Writing soapUI response to the file
inputFileResponse.write(context.testCase.getTestStepByName(it.name).getProperty("response").value)

//Writing soapUI request to the file
inputFileRequest.write(context.testCase.getTestStepByName(it.name).getProperty("request").value)

}

log.info ("Completed Write")

--------------------------------------------------

I found the following code but I can't get it implemented. I need to get the Raw Request Not the Request with parameters.

messageExchange.getRequestContent().toString()

Please help

3 Replies

  • PaulDonny's avatar
    PaulDonny
    Regular Contributor
    testStep.getPropertyValue("rawRequest");


    That will get your rawRequest from the property value. I am not positive where else it will be stored but that will likely be the easiest way to access it.
  • PaulDonny's avatar
    PaulDonny
    Regular Contributor
    The default properties are stored in the testStep level under Custom Properties. Here is a snippet as an example. It contains a lot of useful stuff.
  • Donovan's avatar
    Donovan
    Occasional Contributor
    Thank you, that works great.

    Where did you find the values for getProperty()?