Skip to Content
author's profile photo Former Member
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 a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on 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 a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.