Forum Discussion

icenamor's avatar
icenamor
Occasional Contributor
5 years ago
Solved

Use a file in a SOAP request

Hi all,  I need to know how do this process. I have a SOAP request that give a attachment file (see File1.PNG) and need to process the file for other request. How can use it automatically?  
  • icenamor's avatar
    icenamor
    5 years ago

    The solution is here: 

     

    def testCaseName = 'Messages-IP-Mail'
    def testStepName = '001_1ConventMailToPDF'
    //context.testCase.testSuite.testCases[testCaseName].testSteps[testStepName].testRequest.responseContent
    def projectDir = context.expand('${projectDir}');
    log.info "Current dir:" + projectDir
    def response = context.testCase.testSuite.testCases[testCaseName].testSteps[testStepName].testRequest.response.getAttachments()
    def fileName = projectDir + '/pdf.pdf'
    def outFile = new FileOutputStream(new File(fileName))
    testRunner.testCase.testSteps["testStepName"].setPropertyValue("fileName", fileName)
    def ins = response[0].inputStream
    if (ins) {
           com.eviware.soapui.support.Tools.writeAll(outFile, ins)
        }
    ins.close()
    outFile.close()