Forum Discussion

kkiran11's avatar
kkiran11
New Contributor
16 years ago

Save the Raw XML of the Request and Response of the SOAP UI

Hi,
I am using the following code to save the request and the response in the XML file. It works fine but I want to save the Raw data instead of the XML. how can I do this.

def testRequest = testRunner.testCase.testSteps["Create"].testRequest
def file = new PrintWriter("C:/Request.xml")
log.info(testRequest.response.contentAsString)
file.println( testRequest.requestContent )
file.println( "==============End of Request=============")
file.println( testRequest.response.contentAsString )
file.flush()
file.close()

This code saves the XML Request and Response, but I want to Save the Raw Data in the File.

Regards,
Kiran K
  • juanteit's avatar
    juanteit
    New Contributor
    Sorry, I have no answer, but a similar question:

    I have a request with variables:

     

     
         
           
           
    ...

    In the raw tab of the test step, I have:


     

     
         
           
           
    ...


    I want to put into a file the raw version with groovy. How can I do that? I tried:

    def response = context.testCase.testSteps["bookReservation - Requete base 2"].properties
    log.info (response["Request"].value)

    It gives the xml tab version.

    I also tried:
    holderReq = groovyUtils.getXmlHolder (requestname + "#Request")
    fileReq = new File( context.getProperty("test_folder") + "\\" + requestname + "-Req.xml" )
    writer = fileReq.newWriter()
    writer.writeLine(holderReq.xml)
    writer.close()

    It gives the xml tab version.
  • juanteit's avatar
    juanteit
    New Contributor
    I found an answer, so I let you know:

    To save the raw data, I access to my xml during test case execution using:

    testRunner.getResults().getRequestContent()
    testRunner.getResults().getResponseContent()


    i is an integer, that may be obtained by:
    i = testRunner.testCase.getTestStepIndexByName("My Test Step")

    Hope it helps anybody...
  • Lohith's avatar
    Lohith
    New Contributor
    Hi Juanteit,

    Can you please elaborate on ur reply

    Thanks
    Lohith