shapani
13 years agoOccasional Contributor
Help needed to print Http request from grrovy script in soap
Hi All,
I got stuck for printing Http request in logfile using groovy script. The same code works for printing the http response.
------------------------------------------------------
import com.eviware.soapui.model.testsuite.TestCaseRunner
import com.eviware.soapui.model.testsuite.TestRunner.Status
import com.eviware.soapui.support.XmlHolder
import com.eviware.soapui.model.testsuite.TestStepResult
import com.eviware.soapui.impl.wsdl.teststeps.HttpTestRequest
import com.eviware.soapui.model.iface.MessageExchange
def useridEtn;
def targetStep;
def userId;
def objLog;
def stringRequest;
com.eviware.soapui.model.testsuite.TestStepResult targetStep1
com.eviware.soapui.impl.wsdl.teststeps.HttpTestRequest testRequest
com.eviware.soapui.model.iface.MessageExchange messageExchange
objLog = new library.LogResult(context.expand( '${#Project#logFilePath}' ))
objLog.logScriptStart("Release Checkout")
//-------------------Execute the API - get_p**s-----------//
targetStep1 = testRunner.runTestStepByName("get_p**s")
objLog.logHTTPTestRequestResult("get_p**s", targetStep1)
//Logging the Request/Response onto a file
log.info new String( messageExchange.getRawRequestData() );
request = context.expand('${get_plans#Request}')
log.info (request.toString());
response = context.expand('${get_plans#Response}')
objLog.logResponse("get_plans", response)
Note: I have also tried below code as it was suggested in forum. But it throws an error missing property getRawRequestData() for messageExchange.
log.info new String( messageExchange.getRawRequestData() );
Thanks in advance for your help.
Regards,
-Shital
I got stuck for printing Http request in logfile using groovy script. The same code works for printing the http response.
------------------------------------------------------
import com.eviware.soapui.model.testsuite.TestCaseRunner
import com.eviware.soapui.model.testsuite.TestRunner.Status
import com.eviware.soapui.support.XmlHolder
import com.eviware.soapui.model.testsuite.TestStepResult
import com.eviware.soapui.impl.wsdl.teststeps.HttpTestRequest
import com.eviware.soapui.model.iface.MessageExchange
def useridEtn;
def targetStep;
def userId;
def objLog;
def stringRequest;
com.eviware.soapui.model.testsuite.TestStepResult targetStep1
com.eviware.soapui.impl.wsdl.teststeps.HttpTestRequest testRequest
com.eviware.soapui.model.iface.MessageExchange messageExchange
objLog = new library.LogResult(context.expand( '${#Project#logFilePath}' ))
objLog.logScriptStart("Release Checkout")
//-------------------Execute the API - get_p**s-----------//
targetStep1 = testRunner.runTestStepByName("get_p**s")
objLog.logHTTPTestRequestResult("get_p**s", targetStep1)
//Logging the Request/Response onto a file
log.info new String( messageExchange.getRawRequestData() );
request = context.expand('${get_plans#Request}')
log.info (request.toString());
response = context.expand('${get_plans#Response}')
objLog.logResponse("get_plans", response)
Note: I have also tried below code as it was suggested in forum. But it throws an error missing property getRawRequestData() for messageExchange.
log.info new String( messageExchange.getRawRequestData() );
Thanks in advance for your help.
Regards,
-Shital