Donovan
11 years agoOccasional Contributor
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
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