Forum Discussion

SuperSingh's avatar
SuperSingh
Contributor
9 years ago
Solved

Saving request and response to an external file for "JDBC Request" and "Groovy Scripts"

I have script that saves Request and Response XML's (to an external file) for my regular REST calls in SoapUI.

 

However, I want to save the Request and Response of the following

1. JDBC Step (Request contains SQL Queries || Response has the output for the same)

2. Groovy Script(Request contains script to extract Specific Nodes || Response has the data in customized format )

 

Would be great, if someone can help me here.

 

Thanks in advance ,

Predator

  • SuperSingh's avatar
    SuperSingh
    9 years ago

    I got it . The following is the difference and it works.

     

    def ResFile ="C:/Testing Lab/Soap TestBed/Response Data/Response1.xml"
    def Res = context.expand( '${Rate#ResponseAsXml}' )
    def j = new File(ResFile)
    j.write(Res, "UTF-8")

     

    Thanks all for the help !

     

    Thanks,

    PredatorSingh

10 Replies

  • nmrao's avatar
    nmrao
    Community Hero
    Can you show your existing script which saves the request and response xmls?

    Probably that can be used or used that quick code to adopt for the above requests.
    • SuperSingh's avatar
      SuperSingh
      Contributor

      Here's the sample that copies my request and response and stores it externally.

       

      def ReqFile ="C:/Testing Lab/Soap TestBed/Response Data/ReqFile1.xml"
      def Req = context.expand( '${Rate#Request}' )
      def i = new File(ReqFile )
      i.write(Req, "UTF-8")

       

      def ResFile ="C:/Testing Lab/Soap TestBed/Response Data/Response1.xml"
      def Res = context.expand( '${Rate#Response}' )
      def j = new File(ResFile)
      j.write(Res, "UTF-8")

       

      Thanks,

      Predator

      • Amyread's avatar
        Amyread
        Occasional Contributor

         

        I am using this code to retrieve response in a test suite. Can you please help

         

        I have a test suite with few rest api test cases.

        I need to automatically save all responses in a folder when the test suite is run with the test case name.xml

         

         

        def ReqFile ="C:/soapui/environment/DEV Environmentl"
        def Req = context.expand( '${Rate#Request}' )
        def i = new File(ReqFile )
        i.write(Req, "UTF-8")

    • SuperSingh's avatar
      SuperSingh
      Contributor

      I've shared the script you've asked for. I tried fitting my JDBC in that script, but doesn't work.

      Appreciate any help here.

       

      Thanks,

      Predator.

      • nmrao's avatar
        nmrao
        Community Hero
        SuperSingh,

        Have you tried the same context.expand( '${JDBCTestStep#Request}' ) - change the test step name in place of JDBCTestStep and the same for response as well.

        If you have already tried that and still did not work? then quite strange.