Saving attachments automatically
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2007
01:32 AM
11-02-2007
01:32 AM
Saving attachments automatically
I am testing a webservice that returns an attachment (MIME).
Is there a way to automatically save the retrieved attachment, preferably to a filename and folder that I can specify.
I know I can manually save attachments, but I would like to do that automatically, as part of a testsuite>testcase>teststep.
Maybe by using a particular assertion script?
Is there a way to automatically save the retrieved attachment, preferably to a filename and folder that I can specify.
I know I can manually save attachments, but I would like to do that automatically, as part of a testsuite>testcase>teststep.
Maybe by using a particular assertion script?
3 REPLIES 3
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2007
02:05 AM
11-02-2007
02:05 AM
Hi!
sure.. create a groovy script step after your request and use something like the following:
def testStep = testRunner.testCase.getTestStepByName( "request.." )
def response = testStep.testRequest.response
def outFile = new java.io.FileOutputStream( "myfile..")
def in = response.attachments[0].inputStream
com.eviware.soapui.support.Tools.writeAll( outFile, in )
Hope I got that right.. 🙂
regards!
/Ole
eviware.com
sure.. create a groovy script step after your request and use something like the following:
def testStep = testRunner.testCase.getTestStepByName( "request.." )
def response = testStep.testRequest.response
def outFile = new java.io.FileOutputStream( "myfile..")
def in = response.attachments[0].inputStream
com.eviware.soapui.support.Tools.writeAll( outFile, in )
Hope I got that right.. 🙂
regards!
/Ole
eviware.com
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2016
10:59 PM
05-01-2016
10:59 PM
Thank you for the code snippet. Found that few changes needed though :
1. 'in' is a groovy keyword
2. both in and out streams to be closed, otherwise content is not save and not allowed to open file.
Here is the updated script, using it as script assertion:
def response = messageExchange.response assert null != response, "response is null" def outFile = new FileOutputStream(new File(System.getProperty('java.io.tmpdir')+'/test.zip')) def ins = messageExchange.responseAttachments[0].inputStream if (ins) { com.eviware.soapui.support.Tools.writeAll( outFile, ins ) } ins.close() outFile.close()
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2016
01:39 AM
06-28-2016
01:39 AM
Hi guys,
I am complete newbie to this SOAPui. I am trying to get the same response MIME image/jpeg file as attachment. I have attached the jpeg file in the request area. Can you give me a detailed step on how to do this ?
