Hi, I'm trying to use SOAP Message Transmission Optimization Mechanism (MTOM) with CMIS services to upload large files (over 500Mb) to Alfresco 3.3g Community.File downloading works fine with MTOM, that is
ObjectServicePort port = Service.create(wsdlUrl, serviceName).getPort(ObjectServicePort.class, new MTOMFeature());
CmisContentStreamType content = port.getContentStream(repoId, largeObjectId, null, null, null, null);
DataHandler stream = content.getStream();
OutputStream os = new FileOutputStream(DOWNLOAD_PATH);
stream.writeTo(os);
os.close();
uses single small buffer multiple times to transfer the file from Alfresco. It doesn't allocate a buffer of the size of the file, so it doesn't need much memory to run.However, while uploading with MTOM
ObjectServicePort port = Service.create(wsdlUrl, serviceName).getPort(ObjectServicePort.class, new MTOMFeature());
CmisContentStreamType content = port.getContentStream(repoId, largeObjectId, null, null, null, null);
// These are required to turn MTOM on in jax-ws client
Map<String, Object> ctxt = ((BindingProvider)port).getRequestContext();
ctxt.put(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 8192);
final FileInputStream is = new FileInputStream(FILE_TO_UPLOAD);
DataHandler stream = new DataHandler(new DataSource() {
@Override
public OutputStream getOutputStream() throws IOException {
return null;
}
@Override
public String getName() {
return "";
}
@Override
public InputStream getInputStream() throws IOException {
return is;
}
@Override
public String getContentType() {
return "application/octet-stream";
}
});
CmisContentStreamType contentStream = new CmisContentStreamType();
contentStream.setMimeType("application/octet-stream");
contentStream.setStream(stream);
port.setContentStream(repoId, new Holder<String>(largeObjectId), true, null, contentStream, null);
it tries to allocate a buffer to hold the whole file read from FileInputStream and ends up with "java.lang.OutOfMemoryError: Java heap space"This method does work with a test MTOM-enabled web service, but for some reason it fails to work with CmisObjectService. What am I doing wrong? Is there any way to get upload streaming to work with CMIS?