Hello everybody,
We have a CXF webservice that is a kind of "repository service" and a webapp
working as frontend for that repository.
Those two components are on separate hosts.
We would need to realize a continuous stream of data when downloading
attachments from CXF webservice to the users' browser through the frontend
webapp.
The webapp is basically a servlet that invokes the webservice, receives the
attachment datahandler and copies datahandler InputStream to servlet
response OutputStream (servlet code is at the end of this email).
Our issue: is it possible to directly link datahandler InputStream to
servlet response OutputStream without re-building the whole attachment in
memoroy or in a temporary file? (as can be configured by setting
org.apache.cxf.io.CachedOutputStream.Threshold,
org.apache.cxf.io.CachedOutputStream.OutputDirectory)
Going more into details, is there a way to send to CXF the output buffer to
write the attachment on? In such case we would send to CXF the sevlet's
output buffer.
Alternatively, is there a way to manage CXF working asynchronously with
attachments, giving back control to the servlet before attachment downolad
completion?
Many thanks,
Marco
---
This is the servlet's involved code:
...
StreamingService_Service ss = new StreamingService_Service(new
URL(serviceURL));
StreamingService port = ss.getServiceImplPort(new MTOMFeature());
Resume myFile = port.downloadMethod(fileName, fileType, usr, pwd, repo);
DataHandler handler = myFile.getResume();
response.setHeader("Pragma", "No-cache");
response.setContentType("application/octet-stream");
response.setHeader("content-disposition", "attachment; filename=" + fileName
+ "." + fileType);
try {
InputStream is = handler.getInputStream();
try {
OutputStream os = response.getOutputStream();
try {
byte[] b = new byte[100000];
int bytesRead = 0;
while ((bytesRead = is.read(b)) != -1) {
os.write(b, 0, bytesRead);
}
System.out.println("Download del file " +
myFile.getCandidateName() + "."
+ myFile.getResumeFileType() + " completato.");
} finally {
os.flush();
os.close();
}
} finally {
is.close();
}
} catch (Exception e) {
e.printStackTrace();
}
...
--
View this message in context:
http://www.nabble.com/Streaming-large-attachments-by-linking-input-and-output-stream-avoiding-temp-files-tp24677330p24677330.html
Sent from the cxf-user mailing list archive at Nabble.com.