Forum Discussion

Clawzix's avatar
Clawzix
Occasional Contributor
3 years ago
Solved

How to get a file which is in a tag?

Hello,

 

Sorry, I don't speak english really well...

 

I made a request based on a wsdl, i was searching for a .zip file and I got it in a tag.

Please can you tell me how to make this file in a directory in my computer?

 

Thank you in advance!

Kind regards Clawzix.

 

nmraoI know that you are helpfull for SoapUI users please help me if you can.. I need an answer as quick as possible..

  • nmrao's avatar
    nmrao
    3 years ago

    Clawzix 

    This is based the image you provided.

    Script is based on assumptions. you need to test it.

    Add the below script as Script Assertion for the SOAP Request test step

     

     

    assert context.response
    def zipContent = new XmlSlurper().parseText(context.response).'**'.find{it.name() == 'MessageZip'}.text()
    def zipFile = new FileOutputStream(new File(System.getProperty('java.io.tmpdir')+'/test.zip'))
    def inStream =  new ByteArrayInputStream( zipContent.getBytes( 'UTF-8' ) )
    if (inStream) {
       com.eviware.soapui.support.Tools.writeAll(zipFile, inStream)
    }
    inStream.close()
    zipFile.close()

     

     

16 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    Sorry I did not under the question. May explain a bit more probably with a screen shot?

    Do you mean to save the attachment from the response?
    • Clawzix's avatar
      Clawzix
      Occasional Contributor

      There is my file, how to get it?

    • Clawzix's avatar
      Clawzix
      Occasional Contributor

      Sorry but my file is not an attachement, it is not in the attachement tab..

      • nmrao's avatar
        nmrao
        Champion Level 3

        Clawzix 

        This is based the image you provided.

        Script is based on assumptions. you need to test it.

        Add the below script as Script Assertion for the SOAP Request test step

         

         

        assert context.response
        def zipContent = new XmlSlurper().parseText(context.response).'**'.find{it.name() == 'MessageZip'}.text()
        def zipFile = new FileOutputStream(new File(System.getProperty('java.io.tmpdir')+'/test.zip'))
        def inStream =  new ByteArrayInputStream( zipContent.getBytes( 'UTF-8' ) )
        if (inStream) {
           com.eviware.soapui.support.Tools.writeAll(zipFile, inStream)
        }
        inStream.close()
        zipFile.close()