Responder with MIME type application/pdf
Hello,
I want to add new responder to my virtual asset that returns application/pdf but I don't see the MIME type application/pdf available. Not sure if I am missing something. Please let me know if anyone handled a response of type application/pdf from parasoft.
Comments
-
but I don't see the MIME type application/pdf available
I notice that only textual MIME types are listed here. The "MIME type" selection is only present when "Text" is selected which is why it only lists textual media types. To send a binary file like a pdf you need to pick File instead.
You can configure the HTTP "Content-Type" header on the Transport Header tab.
0 -
You may also consider posting your question to the Virtualize forum next time.
1 -
Hi,
How are you providing the pdf file that is being sent back in the response? If you are using a "file" to provide the pdf then you could set a custom HTTP header to indicate the desired mime type.
0 -
@williammccusker @benken_parasoft
Thanks for your response. My requirement a little different. I want to return the base64 format of the pdf in response instead of the pdf itself. The next layer would encode the base64 message and generate pdf. Do you think I should select a different MIME type other than application/pdf in my case?0 -
I want to return the base64 format of the pdf in response instead of the pdf itself.
Is the entire response payload just a base64 encoded pdf? Or is the pdf base64 encoded within an XML element or JSON String? Depending on the situation, you may need to script the response. If you were to script the response, you could use
java.util.Base64.getEncoder().encodeToString(bytes)
from a Groovy script, for example. If your response is XML or JSON, and described by a service definition or schema that indicates which elements are binary, then the Form Input or Form JSON view will provide controls to select the file and base64 the contents automatically.Do you think I should select a different MIME type other than application/pdf in my case?
What MIME type does the service you are virtualizing actually return? I suspect it isn't application/pdf if it is not the raw pdf but something else that contains a base64 encoded version of the pdf.
1 -
@benken_parasoft My problem is solved with your simple solution! I just needed to configure the Content-Type in Transport Header tab. Thanks so much.
1