How to download decrypted pdf document in Traffic response for get method call

ParasofttoudayaParasofttoudaya Posts: 232 ✭✭

Hi Team,

We are getting a pdf file in response as decrypted format for Get method call. There is no option to download the file in response.

Header :
Content-Disposition: attachment; filename="Temp.pdf"

Same service working fine in Postman and able to download the pdf document, please let us know the download option for Parasoft tool.




  • benken_parasoftbenken_parasoft Posts: 901 ✭✭✭
    edited January 2019

    In the past, I've seen users handle this with an Extension Tool chained to the tool's Response output. This seems to work:

    import com.parasoft.api.*
    import org.jvnet.mimepull.*
    void getAttachment(Object input, ScriptingContext context) {
        String inputStr = input.toString()
        String boundary = inputStr.substring(2, inputStr.indexOf('\r'))
        byte[] rawBytes = inputStr.getBytes("ISO-8859-1")
        MIMEMessage mimeMessage = null
        try {
            mimeMessage = new MIMEMessage(new ByteArrayInputStream(rawBytes), boundary)
            MIMEPart mimePart = mimeMessage.getPart(0)
            String contentDisposition = mimePart.getHeader("Content-Disposition").get(0)
            String fileName = contentDisposition.substring(contentDisposition.indexOf("filename=") + 9)
            mimePart.moveTo(new File("C:/somefolder/" + fileName))
        } finally {
            if (mimeMessage != null) {

    You'll can tweak this script as needed, like change which MIME part it is getting in the call to mimeMessage.getPart(int index), and change which file the attachment is written to.

  • ParasofttoudayaParasofttoudaya Posts: 232 ✭✭
    edited January 2019

    Thanks @benken_parasoft Do we have feature request in progress for this? If not, would be possible to create it? It would be easier to have as settings.

  • benken_parasoftbenken_parasoft Posts: 901 ✭✭✭

    Do we have feature request in progress for this?

    Yes. There's a long outstanding feature request (SOA-4428). For background, SOAtest has a tool called the Attachment Handler which was created for the SOAP Client (SOAtest) and Message Responder (Virtualize) for consuming multi-part SOAP payloads, implementing MTOM and SwA SOAP specifications. However, it isn't currently able to be used with other client tools.

  • reactancexlreactancexl Posts: 139

    Has this ever been resolved? 9.10.7 version?

  • jakubiakjakubiak Posts: 684 admin

    Unfortunately built-in support for this has not yet been added and there is no defined timeframe right now. A script like the one mentioned by @benken_parasoft should still be used.

Sign In or Register to comment.