axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nazi, Camille" <Camille.N...@ihsenergy.com>
Subject Axis2 MTOM - File size limit
Date Thu, 02 Nov 2006 23:32:46 GMT
Hi all,

I am using MTOM with Axis2.   I took the MTOM sample bundled with Axis2
and switched it around to where the client sends in the name of the file
to retrieve and the Service returns the file back to the Client and then
the client saves the file to disk (All this is done on my desktop in
windows XP).   I am running axis2 WAR under JBOSS-4.03SP1.

 

The problem I am running into is that for Zip files larger in size than
3.4 Meg, I am not able to open the Zip files with Winzip and I get an
error:

Start of central directory not found; Zip file corrupt.  Possible cause:
file transfer error.

 

 

P.S.:   The file size returned is always exact size as the original file
(looking at it via File Explorer).  It works very well for files less
than 3.4 Meg (Zip files or any other files).

I ran this code against a 5 Meg word file and I was able to open it
fine, so it might be only an issue with zip files.

 

 

Is there a size limit somewhere that I need to change?   Anyone knows
why I might be running into this issue?  Is there anything I am missing
or have incorrect in my Save routine on the client side ?  

I need this tool to be able to return large files from the service,
which sizewise it appears to be returning them correctly, but file is
corrupt.

 

Here's my Service code:

 

import java.io.File;

import java.util.Iterator;

 

import javax.activation.DataHandler;

import javax.activation.FileDataSource;

 

import org.apache.axiom.om.OMAbstractFactory;

import org.apache.axiom.om.OMElement;

import org.apache.axiom.om.OMFactory;

import org.apache.axiom.om.OMNamespace;

import org.apache.axiom.om.OMText;

import org.apache.axis2.AxisFault;

 

public class MTOMProtoService {

 

 

      public OMElement getFile(OMElement element) throws Exception {

            OMElement _fileNameEle = null;

            OMElement _imageElement = null;

            File inputFile = null;

 

            System.out.println("in Method getFile, OMElement received =
" + element.toString());

 

 

            for (Iterator _iterator = element.getChildElements();
_iterator.hasNext();) {

                  OMElement _ele = (OMElement) _iterator.next();

                  System.out.println("in Method for loop in getFile,
OMElement = " + _ele.toString());

                  if (_ele.getLocalName().equalsIgnoreCase("fileName"))
{

                        _fileNameEle = _ele;

                        System.out.println(" Found _fileNameEle =  " +
_fileNameEle);

                  }

            }

 

            if (_fileNameEle == null ) {

                  throw new AxisFault("Either Image or FileName is
null");

            }

 

            String fileName = _fileNameEle.getText();

            OMFactory fac = OMAbstractFactory.getOMFactory();

            OMNamespace omNs =
fac.createOMNamespace("http://localhost/my", "my");

 

            OMElement data = fac.createOMElement("getFile", omNs);

            OMElement fileOME = fac.createOMElement("file", omNs);

            FileDataSource dataSource = new FileDataSource(fileName);


            DataHandler expectedDH = new DataHandler(dataSource);


            OMText textData = fac.createOMText(expectedDH, true);

            fileOME.addChild(textData);

 

            OMElement fileOMEName = fac.createOMElement("fileName",
omNs);

            if (fileName != null) {

                  fileOMEName.setText(fileName);

            }

            data.addChild(fileOMEName);

            data.addChild(fileOME);

            return data;

      }

 

 

 

Save in Client Code:

 

    public void save(OMElement element) throws Exception {

          OMElement _fileNameEle = null;

          OMElement _fileElement = null;

          for (Iterator _iterator = element.getChildElements();
_iterator.hasNext();) {

            OMElement _ele = (OMElement) _iterator.next();

            if (_ele.getLocalName().equalsIgnoreCase("fileName")) {

                  _fileNameEle = _ele;

            }

            if (_ele.getLocalName().equalsIgnoreCase("file")) {

                  _fileElement = _ele;

            }

 

          }       

        OMText binaryNode = (OMText) _fileElement.getFirstOMChild();

        //Extracting the data and saving

        DataHandler     actualDH = (DataHandler)
binaryNode.getDataHandler();

//        File file = new File(desiredFileName);

         // desiredFileName is the output filename to save it under.

        OutputStream os = new FileOutputStream(desiredFileName);

        actualDH.writeTo(os);

        os.close();

   }

 

 

Thanks in advance,

Camille


Mime
View raw message