Add a attachment with a jpeg file to a soap messages

From: Antonio (aborreg1_at_corp.vodafone.es)
Date: 02/20/04


Date: 20 Feb 2004 05:24:56 -0800

Hi everybody!!

First of all, sorry about my english. I promise to improve it. I have
a big problem when I try to add an attachment which contains a image
in it. I have to solve it as soon as possible so i would really
appreciate any help.
The mistake thrown is the following:

javax.activation.UnsupportedDataTypeException: no object DCH for MIME
type image/gif at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:851)
        at javax.activation.DataHandler.writeTo(DataHandler.java:305)
        at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1089)
        at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:635)
        at javax.mail.internet.MimeMultipart.writeTo(MimeMultipart.java:233)
        at com.sun.xml.messaging.saaj.soap.MessageImpl.saveChanges(MessageImpl.java:563)
at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.post(HttpSOAPConnection.java:223)
at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection$PriviledgedPost.run(HttpSOAPConnection.java:151)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.call(HttpSOAPConnection.java:121)
        at com.vod.mm7inbound.GenericListenerThread.run(GenericListenerThread.java:221)
        at java.lang.Thread.run(Thread.java:536)
Feb 20, 2004 12:43:54 PM com.sun.xml.messaging.saaj.soap.MessageImpl
saveChanges
SEVERE: SAAJ0540: Error during saving a multipart message
com.sun.xml.messaging.saaj.SOAPExceptionImpl: Error during saving a
multipart message

The code is this:

***********************************************************************************************

File fd = new File("/home/tibco/products/adapters/development/esther/mm7inbound/scripts/1.gif");
FileInputStream miFicheroSt = new FileInputStream(fd);
int numb = miFicheroSt.available();
byte[] imagen = new byte[numb];
for (int i= 0; i<numb;i++)
{
 imagen[i]=(byte)miFicheroSt.read();
}
AttachmentPart ap = message.createAttachmentPart();
//DataHandler pdfDH = new DataHandler(miFicheroSt ,"text/plain");
//ap.setDataHandler(pdfDH);
 ap.setContentType("image/gif");
ap.setContent(new ByteArrayInputStream(imagen) ,"image/gif");
message.addAttachmentPart(ap);.

Thanks in advance.
Bye.



Relevant Pages

  • Re: save jpg as tif before editing?
    ... > but not simply resaving it, ... I guess English is not your native language? ... Saving is writing the data in memory ...
    (alt.graphics.photoshop)
  • Re: Cant resist this
    ... Not going out cos ... saving for a stupidly priced kitchen she wants, ... Disablement through accident or bad night on town? ... Mixture of English, Welsh, Scottish and Irish? ...
    (uk.local.kent)
  • Re: Cant resist this
    ... Not going out cos ... saving for a stupidly priced kitchen she wants, ... Disablement through accident or bad night on town? ... Mixture of English, Welsh, Scottish and Irish? ...
    (uk.local.kent)
  • Re: [Paint] starting...
    ... Between saving the world and having a spot of tea smithdoerr said ... Next you'll be getting an English ...
    (rec.games.miniatures.warhammer)