我正在实现多米诺Web服务提供商,其目的是从base64格式流式传输,在消耗Web服务的客户端中,该提供者是一个附件文件,将其转换为文件。在Java开发的Web服务提供商中,我使用流类和MIME类来转换流和文件。Web服务提供商适用于最大5 MB的文件,对于更大的文件,显示了技术时的错误。有人有这个问题吗?有什么方法可以解决吗?
这是Web服务提供商的代码
public class criaAnexo {
private Vector itemsToRecycle;
public void attachDocument( byte[] is) {
// creating the output stream used to create the MIME attachments
try
{
itemsToRecycle = new Vector();
Session session = NotesFactory.createSession();
Database db = session.getDatabase("Serverx", "base.nsf");
if (!db.isOpen())
System.out.println("names2.nsf does not exist on snapper");
else
{
Stream outStream = session.createStream();
outStream.write(is);
session.setConvertMIME(false);
// create the MIME body
Document doc = db.createDocument();
doc.replaceItemValue("Form", "formAttachment");
MIMEEntity body = doc.createMIMEEntity();
// create a child for each attachment<br/>
MIMEEntity child = body.createChildEntity();
// find the fileSuffix<br/>
//String fileSuffix = files[i].substring(files[i].lastIndexOf(".")+1);
String fileSuffix = "pdf";
// set the child to the outstream using a mapped MIME type<br/>
// MIME type mapping see: http://www.w3schools.com/media/media_mimeref.asp
//child.setContentFromBytes(outStream, mapMIMEType(fileSuffix), MIMEEntity.ENC_IDENTITY_BINARY);
child.setContentFromBytes(outStream, "application/pdf", MIMEEntity.ENC_IDENTITY_BINARY);
// set name for file attachment<br/>
MIMEHeader header = child.createHeader("Content-Disposition");
header.setHeaderVal("attachment; filename="teste.pdf"");
// set unique id for file attachment to be able to refer to it<br/>
header = child.createHeader("Content-ID");
header.setHeaderVal("teste.pdf");
//outStream.truncate();
//outStream.close();
outStream.close();
Runtime rt = Runtime.getRuntime();
long total_mem = rt.totalMemory();
long free_mem = rt.freeMemory();
long used_mem = total_mem - free_mem;
System.out.println("Total de Memória:"+total_mem);
System.out.println("Total de Memória livre:"+free_mem);
System.out.println("Total de memoria usada pelo agente: " + used_mem/1048576);
doc.save( true, true );
itemsToRecycle.add(doc);
session.recycle(itemsToRecycle); //recycle all items added to vector
session.recycle();
}
}
catch(Exception e)
{
}
}
}
由于base64编码和其他开销,大于5 MB的文件可能超过您为最大请求内容和<的10 MB限制strong=">最大发布数据的10>服务器的设置。尝试增加它们。
实际上,限制发生在消耗我在多米诺本身中实现的Web服务的客户端中。在问题的描述中引用的技术意味着问题在提供商的一边,但实际上不是。当我在DOT Net上实现Web Service客户端时,该文件是没有问题的。