Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to receive/send files with a java Webservice

I'm writing a WebService in Java that should receive a file as an input, and then the WebService does some processing on that file, and finally it should send a new file to the client. How do I send a file to the client? (and how can I tell them to upload one).

like image 523
MounirReg Avatar asked Dec 27 '25 15:12

MounirReg


2 Answers

Files are generally transferred by encoding them with Base64 and putting them in xsd:base64binary

like image 113
Bozho Avatar answered Dec 31 '25 17:12

Bozho


For large file, look for MTOM (Message Transmission Optimization Mechanism). From JAX-WS Metro Guide: Binary attachment:

MTOM is efficient, in the sense that it doesn't have the 33% size increase penalty that xs:base64Binary has. It is interoperable, in the sense that it is a W3C standard. However, MIME multipart incurs a small cost proportional to the number of attachments, so it is not suitable for a large number of tiny attachments.

like image 34
ewernli Avatar answered Dec 31 '25 19:12

ewernli



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!