Forum Discussion
Hi,
I followed your instructions, created a REST project and under that Test Suite > Test Case > Test Script. Then I created a httprequest. I uploaded a image jpeg file. Along with the httprequest, I am writing a Groovy script to fetch the same uploaded image file as response. I have been followng the thread "https://community.smartbear.com/t5/SoapUI-Open-Source/Saving-attachments-automatically/m-p/122169#M21030" to do the same.
My script is like this:
import java.lang.*
import java.util.*
import java.io.*
import java.net.*
import groovy.lang.*
import groovy.util.*
import java.math.BigInteger
import java.math.BigDecimal
import javax.servlet.http.*
def groovyUtils=new com.eviware.soapui.support.GroovyUtils(context)
import com.eviware.soapui.model.iface.*
def ImageReq = testRunner.testCase.testSteps['LeeChin'].httpRequest.getAttachmentAt(0)
log.info(ImageReq) /* This points to the Request Attachment properly */
def ImageResponse = testRunner.testCase.testSteps['LeeChin'].httpRequest.response
//assert null != response, "response is null"
def outFile = new FileOutputStream(new File(System.getProperty('java.io.tmpdir')+'/test.zip'))
def ins = ImageResponse.getAttachmentAt[0].inputStream /* error */
if (ins) {
com.eviware.soapui.support.Tools.writeAll( outFile, ins )
}
ins.close()
outFile.close()
When I run the script; I get an error No such property "getAttachmentAt"; then I changed it to "responseAttachments"
I again get the same error; what am I doing wrong ?
Related Content
- 5 years ago
- 11 years ago
Recent Discussions
- 3 days ago