cancel
Showing results for 
Search instead for 
Did you mean: 

Blank JDBC response when saved to a file

Rakesh15
Occasional Contributor

Blank JDBC response when saved to a file

The JDBC results are blank when saved in SOAP/REST UI 5.5. The result set has only is 1 or 2 lines

Looking for solutions.

6 REPLIES 6
ChrisAdams
Community Leader

Re: Blank JDBC response when saved to a file

HI,

 

Would you like to provide some more details about what you are trying to achieve and what you expect to happen.  Screenshots would be really helpful too.

Rakesh15
Occasional Contributor

Re: Blank JDBC response when saved to a file

Step 1: I am able to fetch the results using JDBC query

Step 2: Able to export the file to local machine

Step3. My file is blank with no data

 

Below is the snippet I am using 

def ReqFile ="C:/Test/ReqFile1.xml"
def Req = context.expand( '${JDBC#Request}' )
def i = new File(ReqFile )
i.write(Req, "UTF-8")


def ResFile ="C:/Test/Response1.xml"
def Res = context.expand( '${JDBC#Response}' )
def j = new File(ResFile)
j.write(Res, "UTF-8")

 

Below is the JDBC request and output

Rakesh15_1-1613831080359.png

Note: Important I need the Results/Response set to be stored in local

ChrisAdams
Community Leader

Re: Blank JDBC response when saved to a file

Hi,

 

That's much clearer, thank you.  I understand what you're after now.

 

I don't have the means to test until Monday, but in the meantime, have you tried reporting the request and response of Rest/Soap web service call?  If your Groovy works with one of those steps, then maybe there is something different about the JDBC step.

richie
Community Hero

Re: Blank JDBC response when saved to a file

Hey @Rakesh15 

 

have you tried adding logging into your script?

 

i.e. on the next line after 'def Res = context.expand( '${JDBC#Response}' )'

insert 'log.info(Res)'  //adding this should indicate the contents of the Res variable 

 

so your code reads:

 

def Res = context.expand( '${JDBC#Response}' )

log.info(Res)
def j = new File(ResFile)

 

if the file is created fine then it seems logical think the step in the code that passes the content to the variable or the line extracting the value from the variable is where the issues lies adding the log.info (Res) line should help tell us if the response is being passed into the Res variable correctly

 

Also - I've had trouble with JDBC steps in groovy scripting before now - when I wanted the contents of the query results I found  context.expand('${JDBC#Response}') didn't always work, however if I changed this to context.expand ( '${JDBC Request#ResponseAsXml#//Results/*}' ).

 

ta

 

rich

 

 

 

 

${JDBC Request#ResponseAsXml#//Results/*}

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Rakesh15
Occasional Contributor

Re: Blank JDBC response when saved to a file

I was able to resolve the issue

richie
Community Hero

Re: Blank JDBC response when saved to a file

Hey @Rakesh15,

Would you mind detailing how you fixed the issue so that if anyone has the same issue they can fix it also?

Cheers,

Rich
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors