Question

I am implementing a webservice that returns the content of binary files. The files are about 100MB big. The webservice and the client are build upon Axis2.

What is the best joice for the return type of the method that returns the data?

I tried byte[], but I always get OutOfMemoryErrors on the server side. Plus I am not very happy to have the whole file content in memory. Is there something stream-alike that I can use instead?

Was it helpful?

Solution 2

The article "Downloading a Binary File from a Web Service using Axis2 and SOAP with Attachments" describes exactly the solution I was looking for. Big chunks of data are added as attachment to the SOAP response of the webservice using "SOAP with Attachments" (SwA).

I can use a javax.activation.DataSource which provides an InputStream and I do not have to hold the whole file in memory.

OTHER TIPS

Instead of returning the data, can you return a temporary URL pointing to this big result saved as a temporary file ? Or can you return your file as a series of smaller results ?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top