i working on webservice send large pdf files server client using dime. using apache axis2 implementation webservice support. have been service work issue arises when attempt send attachments larger 1mb exception. guess have chunksize attachment before sending have no idea can control , thinking maybe another. below code client uploading files
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(); } } }
and code use process attachments on server side
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) { (int = 0; < 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)) > 0) out.write(buffer, 0, len); out.close(); in.close(); result += "file saved on 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<attachmentpart> iter = attachmentsimpl.getattachments().iterator(); int count = 0; while (iter.hasnext()) { attachmentpart part = iter.next(); attachments[count++] = part; } return attachments; }
if knows issue causing axisfault files larger 1mb appreciate it. thanks.
axis2 not support dime, see previous question: java client calling wse 2.0 dime attachment
Comments
Post a Comment