#web-service #java #reporting

Transfering documents over web service endpoints

Probably anyone who ever dealt with integration of distributed systems, no matter what the programming language is, came upon a use case where a document, such as .pdf, would need to be sent over a java web service. Usual use case involves feeding data to an isolated module for report generation, and obtaining a generated file as a result. Such transfer is not possible with out-of-the-box technologies. There exists no such "return-type" as File in Java Web Services, nor anywhere else. The only way to perform such transfer is to convert the contents of such file into a byte array which can further be packed within the XML response. This means that our report generation endpoint is going to deserialize the java object, turn it into a byte array, send it back to the client, who afterwards needs to serialize it once again into a corresponding java object, that can now be written into a specific file, and offered as a download within a favourite browser. However, beware of the fact that different browsers sometimes require specific settings of your UI framework used for downloading.
Subscribe to #web-service #java #reporting