I'm using Axis2, version 1.5.1, in a Spring 3 web application running in a Tomcat 6 container. I developed a Spring controller that uses the Axis2 framework to instantiate a SOAP client to call an MTOM web service. The MTOM web service returns one file, so multiples are not an issue. I have file caching enabled and I want to be able to stream the file to the user as it is being written to the disk. In fact, if I can get Axis2 to write the file to response instead of the disk, that might work out better. Has anyone done this? I'm looking for a solution or ideas to get me started. I haven't found anything in the documentation to be helpful.
I pasted the start of my code below. Currently after I get the result, I get the DataHandler from the result and begin reading the input stream and writing it out to the response output stream. This method is inefficient because the user is basically downloading the file twice; once to the server and then to the user's machine.
Options options = new Options();
options.setTo(new EndpointReference(this.endpointUrl));
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
// Cache incoming attachments to save on heap usage.
options.setProperty(Constants.Configuration.CACHE_ATTACHMENTS, Constants.VALUE_TRUE);
// Set the directory where the attachments will be temporarily stored.
options.setProperty(Constants.Configuration.ATTACHMENT_TEMP_DIR, "c:\temp");
// Set the threshold in bytes. Attachments that are less than this
// size will not be stored in the temp directory.
options.setProperty(Constants.Configuration.FILE_SIZE_THRESHOLD, "1048576");
options.setTimeOutInMilliSeconds(30000);
ServiceClient sender = new ServiceClient();
sender.setOptions(options);
OMElement result = sender.sendReceive(myOmElement);