Note that there are some explanatory texts on larger screens.

plurals
  1. POApache AXIS2 sending large DIME attachments
    primarykey
    data
    text
    <p>I am currently working on a webservice to send large pdf files to server from client using DIME. I am using apache axis2 implementation for webservice support. I have been to get the service to work but an issue arises when I attempt to send attachments that are larger than 1MB then I get an exception. My guess is I probably would have to chunksize my attachment before sending it but I have no idea for where i can control that and also I am thinking maybe it would be another. Below is the code for the client that is uploading the files</p> <pre><code>public class PdfDriver { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { // TODO Auto-generated method stub testAddGroup(); } public static void testAddGroup() throws IOException { try { PdfMail_ServiceLocator locator = new PdfMail_ServiceLocator(); locator.setPdfMailSOAPEndpointAddress("http://localhost:80/services/PdfMailSOAP"); PdfMail_PortType stub = locator.getPdfMailSOAP(); PdfMailSOAPStub server = null; server = (PdfMailSOAPStub) stub; //Test uploading pdf server._setProperty(Call.ATTACHMENT_ENCAPSULATION_FORMAT, Call.ATTACHMENT_ENCAPSULATION_FORMAT_MTOM); FileDataSource ds = new FileDataSource("/test.zip"); DataHandler dh = new DataHandler(ds); server.addAttachment(dh); System.out.println(server.getTimeout()); Calendar cal = Calendar.getInstance(); long x = cal.getTimeInMillis(); System.out.println("Server: Start receive@ "+ "\n" + server.sendPdf("test.zip") + "\nServer: Finished receive "); } catch (ServiceException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } </code></pre> <p>And this is the code I use to process the attachments on the server side</p> <pre><code>public java.lang.String sendPdf(java.lang.String pdfToSend) throws java.rmi.RemoteException { String result = ""; AttachmentPart[] attachments = null; try { attachments = getAttachments(); } catch (Exception e1) { result = "null attachments getAttachments exception"; e1.printStackTrace(); } if (attachments != null) { for (int i = 0; i &lt; attachments.length; i++) { AttachmentPart attachment = attachments[i]; try { File file = new File(pdfToSend); InputStream in = attachment.getDataHandler().getInputStream(); OutputStream out = new FileOutputStream(file); byte[] buffer = new byte[8192]; int len; while ((len = in.read(buffer)) &gt; 0) out.write(buffer, 0, len); out.close(); in.close(); result += "File saved on the server\nFile Size : " + (file.length() / 1048576) + "MB \nSend Type : " + this.receivedType; } catch (IOException e) { result += "exception IO"; e.printStackTrace(); } catch (SOAPException e) { result += "SOAP exception"; e.printStackTrace(); } } } return result; } private AttachmentPart[] getAttachments() throws Exception { MessageContext msgContext = MessageContext.getCurrentContext(); Message message = msgContext.getRequestMessage(); Attachments attachmentsimpl = message.getAttachmentsImpl(); if (null == attachmentsimpl) { return new AttachmentPart[0]; } int attachmenstCount = attachmentsimpl.getAttachmentCount(); this.receivedType = attachmentsimpl.getSendType(); AttachmentPart attachments[] = new AttachmentPart[attachmenstCount]; Iterator&lt;AttachmentPart&gt; iter = attachmentsimpl.getAttachments().iterator(); int count = 0; while (iter.hasNext()) { AttachmentPart part = iter.next(); attachments[count++] = part; } return attachments; } </code></pre> <p>If anyone knows what the issue would be causing an AxisFault for files larger that 1MB I would appreciate it. Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload