Hi Greg,
 
If ur attachment content is of Content-Type "application/octet-stream" then the  AttachmentPart.getContent() method  will return an object of  Instream which is an Inner Class of ManagedMemoryDataSource.  and this class extends java.io.InputStream.  (Reference Axis 1.1 Source)
 
So if you type cast the return of  AttachmentPart.getContent()  with an InputStream it works fine and you will be able to save the file (Refer Code below).
   
    AttachmentPart attachment = (AttachmentPart)enumAttachment.nextElement();
    
    if ((attachment.getContentType()).equals("application/octet-stream"))
    {          
       InputStream is = (InputStream)attachment.getContent();     
     int filSize= attachment.getSize();     
     System.out.println("Got Size "+filSize);          
     byte [] byteArray= new byte[filSize];   
     System.out.println("Got byte array");          
     int ch = is.read(byteArray,0,filSize);
     System.out.println("Read to Byte Array");          
     System.out.println("Creating FOS");   
     FileOutputStream fosOct = new FileOutputStream("D:\\mime_ws\\attachs\\"+enumFile.nextElement());        
     System.out.println("Created FOS");          
     System.out.println("Writing the Byte Array to File");          
     fosOct.write(byteArray);
     System.out.println("Wrote to file ");
     fosOct.close();       
    }
 
 
The above code works fine for me on Axis 1.1
Hope this helps you. If you are so particular of MMDS then I havent used it. I have tested a 10 MB file sucessfuly.
 
Cheers
 
Dhanush Gopinath
Software Engineer
Mahindra British Telecom Ltd
+91-020-4018100 Ext:-1218

"Fate, it seems, is not without a sense of irony" - Morpheus , The Matrix
----- Original Message -----
From: Greg Hess
Sent: Wednesday, July 07, 2004 12:11 AM
Subject: Using ManagedMemoryDataSource?

Hi All,

 

I am presently using the “manual method” for adding and receiving attachments for my web service. Some of my attachments are quite large and I would like to use the ManagedMemoryDataSource to optimize my implementation.

 

In testing when I construct a new instance of ManagedMemoryDataSource to use with my attachments I pass it an InputStream to read from and manage appropriately(either save to file or mem) but when I obtain an InputStream from the MMDS instance it has 0 bytes available.

 

 

InputStream is = dao.getData();

//is has data to read

 

ManagedMemoryDataSource mmds = new ManagedMemoryDataSource(is, ManagedMemoryDataSource.MAX_MEMORY_DISK_CACHED, “application/octet-stream”);

 

is= mmds.getInputStream();

//is has no data to read?????

 

Does anyone know how to use this class?

 

Many thanks,

 

Greg Hess

Software Engineer

Wrapped Apps Corporation

275 Michael Cowpland Dr.

Suite 201

Ottawa, Ontario

K2M 2G2

Tel: (613) 591 -7552 ext 230

Fax: (613) 591-0523

1 (877) 388-6742

www.wrappedapps.com

 

********************************************************* Disclaimer: This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law. If you are not the intended recipient, you should delete this message and are hereby notified that any disclosure, copying, or distribution of this message, or the taking of any action based on it, is strictly prohibited. ********************************************************* Visit us at http://www.mahindrabt.com

<<image001.gif>>

Reply via email to