mercredi 28 juin 2017

Domino web service provider limitation

I'm implementing a domino web service provider, whose purpose is to stream from the base64 format, which in the client that consumes the web service is an attachment file, transform it back into a file. In the web service provider that is developed in java, I use the Stream class and the Mime classes to, to convert the stream and file. The web service provider works well for files up to 5 MB, for larger files the error as technote is displayed. Has anyone had this problem yet? Is there any way around it?

Here is the code for the web service provider

public class criaAnexo {
private Vector itemsToRecycle;
public void attachDocument( byte[] is) {

    // creating the output stream used to create the MIME attachments
    try
    {
        System.out.println("OK 0");
        itemsToRecycle = new Vector(); 
        Session session = NotesFactory.createSession();
        Database db = session.getDatabase("Snmb04/Mercantil do Brasil", "MB_Web_Services_NTS_AgendamentoParceiro.nsf");
        if (!db.isOpen())
            System.out.println("names2.nsf does not exist on snapper");
        else
        {
            Stream outStream = session.createStream();
            System.out.println("OK 1");
            outStream.write(is);
            System.out.println("OK 2");


            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://ift.tt/1mOwCIh

            //child.setContentFromBytes(outStream, mapMIMEType(fileSuffix), MIMEEntity.ENC_IDENTITY_BINARY);

            child.setContentFromBytes(outStream, "application/pdf", MIMEEntity.ENC_IDENTITY_BINARY);

            System.out.println("OK 3");
            // set name for file attachment<br/>
            MIMEHeader header = child.createHeader("Content-Disposition");
            header.setHeaderVal("attachment; filename=\"teste.pdf\"");

            System.out.println("OK 4");
            // 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)
    {
    }
}

}




Aucun commentaire:

Enregistrer un commentaire