I am having difficulty receiving a PDF file via a rest service. The rest service returns a long string with the data that is suppose to make up the PDF. My overall goal is to save the response as a PDF file for later use.
I call this service url: http://4.hidemyass.com/ip-2/encrypted/dnXuHKAZVZaONS2GNfC9RFn8k8puE2YJx6MjcPDMaKdpMRTBkvNF4CrTg4m7GeKjcLfO1bgYWIwR9bz1ZJP-LTK6Gm8tG_-d4V-oSUMfT-tIJMuZizsz9AeZp5tcZWVcz62A6j7YRWqJRAS_s_cMFLlo&f=norefer
and according the docs, it should be the string contents that make up a valid PDF.
What am I missing? What do I need to do in order to make is viewable as a PDF.
Thanks!
Chuc
Sorry the above link failed.
In the end we found that sending the PDF as binary data wrapped in JSON did not work very well. The creators of the service found that their framework was manipulating the binary data ever so slightly and converting some characters. They ended up switching to Base 64 encoding which worked great.
Related
I am building a JSP application. I am trying to send an screenshot image from the page to the servlet by using base64 encoding. It makes the returning string super long with 100k characters length. So when I post this to the servlet and with getParameter, I am getting null there.
Is there a way to get them by chunks are am I missing something?
I found this maybe useful for you.
Passing a huge String as post parameter to a servlet
Namit Rana:
We used GZip compression/decompression to lower the size of the string. And it worked effectively.
So, the .net service compressed the huge string, sent it to our Servlet. We then decompress it at our server.
I'm working in a team as a developer. We have developed a product where we generate letters by populating some XML file. This XML file ONLY contains some texts that need to show up in a pdf document. We then send this XML across to a different area via a web service (say WS-A) call.
This WS-A returns a generated PDF document as a byte stream. Please note that beside generating a pdf document, the backend of WS-A is responsible for the pdf template and how and where these XML texts are displayed in the document. Everything up to this point is fine.
I also do understand that our team needs to write test cases to make sure the correct XML contents are populated before sending it through WS-A.
My question is, is writing a test case which verifies this pdf has the right "texts" (only text verification) our team's responsibility?
Or is this something the other team (in charge of WS-A backend) has to test to make sure they don't miss anything in their PDF from the XML they have been provided (before sending it back to us as a byte stream)?
Yes and no as, it sounds to me like it is a shared responsibility.
As the developer, it is you and your teams job to make sure that you are sending the correct XML template and data. Where your responsibility ends, is once the data has been sent to the backend and the PDF has been generated. It sounds to me that the text being sent can vary so, I would just let the other team handle that since the variance is likely from their side of things.
I'm handling a Web Service and need some help. The process is that a pdf will be encoded with base64 and sent to my web service. I will then decode it back into a pdf and place it in the appropriate folder. The issue is that the request needs to contain the actual giant base64 string. First question is is this possible. Second, I am using postman to make the requests and was wondering how to even copy the base64 string into it. It seems there's a string limit. Any help would be greatly appreciated.
I don't know about postman but I can suggest to use JAX-RS and implement a ReaderInterceptor and a WriterInterceptor using Base64.Decoder#wrap respectively Base64.Encoder#wrap.
Otherwise, maybe postman has similar features?
Use streams like these as much as possible to reduce memory usage.
Tutorial:
https://jersey.java.net/documentation/latest/filters-and-interceptors.html#d0e9806
Alright it just seems to be an issue with Postman. When you place a string of that size it will give you errors and only put a certain length per line. It will still receive the entire string. I am able to receive it and decode it. Thank you all for your help!
I have a web service I am trying to call from Java. The XSD for the service defines a field as an xsd:base64Binary. I am using maven jaxb2 plugin to generate Java artifacts. The field becomes a byte[] in the generated Java object. The data that comes back in that field is either CSV or XML data depending on what is passed into the service. SoapUI displays the data perfectly (not encoded). Watching the wire with wireshark I can also see the non encoded data. My question is, how do I grab this data as a string in Java? I want to take this data and later write it into a file.
Response looks something like this:
Service Agreement,Interval Start Time,Interval End Time,Quantity,Unit of Measure .... etc.
Relevant bit of XSD:
Relevant bit of generated java:
protected byte[] greenDoc;
In my client java code I have been trying every possible combination of new String(byte[]), new String(byte[], charset), Base64 decoding, etc. and I just cannot seem to get the data correctly. I know it is not a limitation of the web service because like I said SoapUI can display the data perfectly.
Any pointers on how the client code can take the byte array and convert to string? Thanks!
Programmatically, you can use DatatypeConverter
I am trying to encode Arabic text from a Web service. Currently the values come as question marks (???).
I have read many blogs (even stackoverflow answers/links) but nothing seems to worked.
Any idea of how I can resolve this issue?
Thanks
If you use dreamweaver's designer view and paste your Arabic text in design view you will get ascii characters in dreamweaver's code view which will work in any web browser.
First, an important aside: check that the web service you are consuming sends you actual Arabic characters and not actual question marks. Check a network dump if you are not sure, and use wget/curl to perform a simple transaction; check the results.
If the raw data as sent by the WS is question marks, you have an uphill battle - try again and fiddle with the Accept/Accept-Charset headers. If all fail, it may be that the server itself isn't coded properly and there ain't much you can do after that...
Also, you're trying to decode the text, convert it from a byte representation to abstract characters.
This has been the problem Sending UTF-8 data from Android. Your code would work fine except that you will have to encode your String to Base64 . At Server PHP you just decode Base64 String back. It worked for me. I can share if you need the code.