title: Open PDF returned by REST Web Service
body: <p>I have a JAXB REST Web Service getting in request a POST of a JSON and should return a PDF document in response:</p>
  
  <pre><code>@POST
  @Path("getReceipt")
  @Consumes({ MediaType.APPLICATION_JSON })
  @Produces({ "application/pdf" })
  public Response getReceipt(InputStream incomingData, @Context HttpServletRequest httpRequest) {
  ...
  }
  </code></pre>
  
  <p>I'm trying to test it with Advanced Rest Client (Google Chrome plugin), which is showing the following as response:</p>
  
  <pre><code>%PDF-1.4
  %����
  3 0 obj
  &lt;&lt;/C[0 0 1]/Border[0 0 0]/A&lt;&lt;/URI(https://www.totalerg.it/)/S/URI&gt;&gt;/Subtype/Link/Rect[491.43 723.5 557 733.5]&gt;&gt;
  endobj
  4 0 obj
  &lt;&lt;/C[0 0 1]/Border[0 0 0]/A&lt;&lt;/URI(https://www.totalerg.it/)/S/URI&gt;&gt;/Subtype/Link/Rect[256.65 274.5 322.22 284.5]&gt;&gt;
  endobj
  5 0 obj
  &lt;&lt;/Length 993/Filter/FlateDecode&gt;&gt;stream
  x��U�n�8}�W�[��Ð����lG�j�릲�}Y0kpaK�,%���s�3vHY����"9�̙G/%&gt;�9��gD������ҙ;�(  \|:+WP�h�|D�zo�����)������h�������L2CR��a�%L�
  ��׷�:��&amp;��g L���1ϲ�Oq���9M�[&lt;�-�ǹ����r���
  wL�2�:W�m#��J��׹\*��":��Ld7�]
  �3�6�E��Kn_&lt;�}�;���,��g�����uk��D^O��6~��Y����]�=1ٸ�gq:���v�l��"��o��x��ǔ�a�09�3H���VeSY?��,�A����l��^*(��W�BE#J�PKX��Fк�s�^��
  �H�)��� ��V��
  �k&lt;���FntUj&lt;��!F�/
  ���U#dU#�q�]ZzUnd�I��Z�w�w'��%��l�4�^!G���~��Ƅ�n��̯�?Ԫ,&amp;�U�1teT"u^���r�P�Bw�:YkLX_:�������ī��Mw��P"���\!%���7����zWO}Yp���h�8�����n�]�� ;x�o�2w�38�ś.��/�~�+e"pC����ڳk�]�c#
  �����E�{�}�nZ��8�35T�IC+��6�6����E���"&gt;J��AZ���F��#��j*����*7�#Pm]����e�e���U�,�؍�!�j�Z��B�de�ҿ�������A֍i����`\T0�0r������Ȇ �G#A��������϶��f���'��׋�͵�,6c�.�4�O�Y:6C.6�}�!]éy�{E߱?��&gt;�&lt;Ƭ�u�y$��9��L���f�]�T��ܸ�/w���������^qj΢[�r��U)g1b������W���Ǥ�*1�؆�������Ȁ8�F�c�ٯB^�bk�n=�?u��x�;�]�H0rsg���tI[x�����G�0�����@p�EW��B�������L�
  endstream
  endobj
  7 0 obj
  &lt;&lt;/Parent 6 0 R/Contents 5 0 R/Type/Page/Resources&lt;&lt;/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]/Font&lt;&lt;/F1 1 0 R/F2 2 0 R&gt;&gt;&gt;&gt;/MediaBox[0 0 595 842]/Annots[3 0 R 4 0 R]&gt;&gt;
  endobj
  1 0 obj
  &lt;&lt;/BaseFont/Helvetica/Type/Font/Encoding/WinAnsiEncoding/Subtype/Type1&gt;&gt;
  endobj
  2 0 obj
  &lt;&lt;/BaseFont/Helvetica-Bold/Type/Font/Encoding/WinAnsiEncoding/Subtype/Type1&gt;&gt;
  endobj
  6 0 obj
  &lt;&lt;/ITXT(2.1.7)/Type/Pages/Count 1/Kids[7 0 R]&gt;&gt;
  endobj
  8 0 obj
  &lt;&lt;/Type/Catalog/Pages 6 0 R&gt;&gt;
  endobj
  9 0 obj
  &lt;&lt;/Producer(iText 2.1.7 by 1T3XT)/ModDate(D:20150907102806+02'00')/CreationDate(D:20150907102806+02'00')&gt;&gt;
  endobj
  xref
  0 10
  0000000000 65535 f 
  0000001518 00000 n 
  0000001606 00000 n 
  0000000015 00000 n 
  0000000142 00000 n 
  0000000272 00000 n 
  0000001699 00000 n 
  0000001332 00000 n 
  0000001762 00000 n 
  0000001807 00000 n 
  trailer
  &lt;&lt;/Root 8 0 R/ID [&lt;f16ea10e09183af8aff079f97cfac53f&gt;&lt;fe60918ac5b80276ed8a082dedebf230&gt;]/Info 9 0 R/Size 10&gt;&gt;
  startxref
  1929
  %%EOF
  </code></pre>
  
  <p>This text version of binary file is different (more question marked characters in place of other ones) from the one I can see opening the binary file from file system with a text editor.</p>
  
  <p>My question is: how could I test this service posting the JSON request and being able to open PDF document in the response? Should I use another tool, or build a form?</p>