Alex,
 
Will sugest you some thing  .. instead of using a datahandler try using InputStream
 
If content type is "application/octet-stream" Get the attachment content from the AttachmentPart to an Input stream  .. and write it out to a File out put stream ..
 
 AttachmentPart attachment = (AttachmentPart)enumAttachment.nextElement();
      if ((attachment.getContentType()).equals("application/octet-stream"))
    {          
       InputStream is = (InputStream)attachment.getContent();     
     
     int filSize= attachment.getSize();
     
        byte [] byteArray= new byte[filSize];
     
        int ch = is.read(byteArray,0,filSize); 
   
        FileOutputStream fosOct = new FileOutputStream("D:\\mime_ws\\attachs\\"+enumFile.nextElement());
 
}
 
This is bcoz for AttachmentPart.getContent() returns an Input Stream for type "application/octet-stream"
 
Hope this helps
 
Cheers
 
Dhanush Gopinath
Software Engineer
Mahindra British Telecom Ltd
+91-020-4018100 Ext:-1218

"It's the possibility of having a dream come true , that makes life interesting" - Paulo Coelho, The Alchemist
----- Original Message -----
From: eagle1978
Sent: Monday, August 02, 2004 7:41 PM
Subject: Problems with DataHandler

Hi,

I've a problem with axis.
I try to develop a webservice application which receives some files and send
some files back.
The webservice is implemented in .NET. (this part works without a problem, I
tested it with a .NET client) The client is implemented in Java.

My problem is how to get the attachment from the webservice answer.

Here is my current code:
      archive.process();
     
      Object attReturn[] = archive.getAttachments();
      int nrAttachments = attReturn.length;
      System.out.println("Anzahl der empfangenen Attachments " +
nrAttachments);
      DataHandler dhReturn;
      OutputStream os;
      FileOutputStream fileOut;

      for (int i = 0; i < nrAttachments - 1; i++) {
        System.out.println(retPath + i + ".txt " + attReturn.length );

        dhReturn = new DataHandler(attReturn[i],
"application/octet-stream");     

        fileOut = new FileOutputStream( retPath + i + ".txt" );
        dhReturn.writeTo(fileOut);
      }

When I run this code I get the following error message:
javax.activation.UnsupportedDataTypeException: no object DCH for MIME type
application/octet-stream

It doesn't matter what kind of mime type I use, I always get the same error
message!
Any suggestions?

Thanks in advance!

Regards
Alex
*********************************************************
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

Reply via email to