Skip to Content
avatar image
Former Member

JavaMail : no object DCH for MIME type Application/XML

Hi,

I am trying to set an Application/XML content on to a MimeBodyPart which results in the following exception:

javax.activation.UnsupportedDataTypeException: no object DCH for MIME type application/xml.

I am getting this error when I am doing an explicit setContent with the "application/xml" content type as depicted below. (The XML content is the form of a byte array.)

ByteArrayOutputStream os = new ByteArrayOutputStream();

os.write(byteArray);

MimeBodyPart mbp = new MimeBodyPart();

mbp.setContent(os, contentType);

In order to avoid this, do I neccessarily have to create a Data content handler for the Application/XML content type? And How do I do it?

I was able to avert this problem through a clumsy way of setting the content as a FileDataSource (fds):

tempFile = File.createTempFile("test","temp");

fos = new FileOutputStream(tempFile);

fos.write(byteArray);

fos.flush();

fos.close();

fds = new FileDataSource(tempFile);

fds.setFileTypeMap(mpFileTypeMap);

DataHandler dh = new DataHandler(fds);

mbp.setDataHandler(dh);

Can somebody point me to the right solution?

Best Regards,

S.Karthik

XI Development

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Mar 09, 2004 at 03:22 PM

    >

    > In order to avoid this, do I necessarily have to

    > create a Data content handler for the Application/XML

    > content type? And How do I do it?

    >

    I would guess so. You can add such a handler in the visual admin in the properties of http service. There is a large string that defines all those content types.

    Your type Application/XML looks a bit weird, as XML usually is transmitted as text....

    Regards,

    Benny

    Add comment
    10|10000 characters needed characters exceeded