cancel
Showing results for 
Search instead for 
Did you mean: 

JavaMail : no object DCH for MIME type Application/XML

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

Benny
Product and Topic Expert
Product and Topic Expert
0 Kudos

>

> 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