Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3798274
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:32:46+00:00 2026-05-19T13:32:46+00:00

I am currently working on a webservice to send large pdf files to server

  • 0

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

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 this is the code I use to process the attachments on the 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)
    {
        for (int i = 0; i < 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 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<AttachmentPart> iter = attachmentsimpl.getAttachments().iterator();
    int count = 0;
    while (iter.hasNext())
    {
        AttachmentPart part = iter.next();
        attachments[count++] = part;
    }
    return attachments;

}

If anyone knows what the issue would be causing an AxisFault for files larger that 1MB I would appreciate it. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T13:32:47+00:00Added an answer on May 19, 2026 at 1:32 pm

    Axis2 does not support DIME, see previous question:
    Java client calling WSE 2.0 with DIME attachment

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently working on an Webservice to retrieve a pdf Document from an
I've been using Apache CXF wsdl2java generated code to call methods from a webservice
I am currently working on an application which needs to send MultiMap from .Net
I am currently working with a webservice to pull a report about users in
Im currently working with an API which requires we send our collection details in
I am working on a c# program that retrieves information from a webservice and
I'm working on a Silverlight app using the MVVM pattern. My ViewModel currently consists
I'm currently working on an application consisting both of a webapplication and client software.
I'm currently working on a WebService that is meant to become used by numerous
I am trying to generate a pdf using the Reporting services 2005 webservice. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.