How to download decrypted pdf document in Traffic response for get method call
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.
Regards
Udaya
Comments
-
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 java.io.* 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) { mimeMessage.close() } } }
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.
0 -
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.
0 -
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.
0 -
Has this ever been resolved? 9.10.7 version?
0 -
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.
0