cancel
Showing results for 
Search instead for 
Did you mean: 

Save attachments automatically in SoapUI with Groovy

SOLVED
Highlighted
Occasional Contributor

Save attachments automatically in SoapUI with Groovy

I try to save all the attachments from a SOAP response. I use following Groovy script.

def testStep = testRunner.testCase.getTestStepByName("SubmitFile")
def response = testStep.testRequest.response
assert null != response, "response is null"
def outFile = new FileOutputStream(new File(System.getProperty('java.io.tmpdir')+'/test.zip'))
for(i=0; i<3; i++){
    def ins =  response.responseAttachments[0].inputStream
    if (ins) {
       com.eviware.soapui.support.Tools.writeAll(outFile, ins)
    }
}
ins.close()
outFile.close()

I get following error message:

No such property : responseAttachments for class

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

Re: Save attachments automatically in SoapUI with Groovy

This

def ins =  response.responseAttachments[0].inputStream

should be

def ins =  response.attachments[0].inputStream

See getAttachments() in interface Response.

View solution in original post

1 REPLY 1
Highlighted
Community Hero

Re: Save attachments automatically in SoapUI with Groovy

This

def ins =  response.responseAttachments[0].inputStream

should be

def ins =  response.attachments[0].inputStream

See getAttachments() in interface Response.

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors