Forum Discussion

icenamor's avatar
icenamor
Occasional Contributor
6 years ago

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?

 

  • 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()
  • richie's avatar
    richie
    Community Hero

    Hi icenamor 

     

    I was going to try and explain - but the help is pretty good on this - please see the following 2 soapui and readyapi! links.

     

    ah - I just re-read your message - are you saying you get a .png file in a SOAP response and you need to pass this onto a subsequent SOAP request?  Anyway - have a look at the links to familiarise yourself -  if this is the case just get things setup to send a file first and then worry about passing it from a response to a request afterwards

     

    Cheers,

     

    rich

    • icenamor's avatar
      icenamor
      Occasional Contributor

      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()