Hi,

I did some more digging, and it seems that this is an issue with SUN's RI of SAAJ, rather than Axiom. In Spring Web Services, I support both SAAJ and Axiom, and have unit tests that test both models. Apparently, the SAAJ AttachmentPart registers it's Java Activation XmlDataContentHandler for "text/xml", which screws up Axiom. Obviously, this is an atypical setup, so I guess that's why nobody saw this issue before.

I've sent a mail to the SAAJ mailing list, informing them of this bug.

Cheers,

Arjen

On 4 jul 2008, at 02:36, Thilina Gunarathne wrote:

Hi,
Just curious whether were you able to get it working on JDK 1.5..

Following is something I never encountered when dealing with DataHandlers
earlier :(..
at
com .sun .xml .internal .messaging .saaj.soap.XmlDataContentHandler.writeTo(XmlDataContentHandler.java: 106)

thanks,
Thilina

On Thu, Jul 3, 2008 at 1:17 PM, Arjen Poutsma <
[EMAIL PROTECTED]> wrote:

Hi,

I've been having some issues with Axiom's SOAP with Attachments' support.
Here's what I try to do, more or less:

SOAPMessage message = ... // an Axiom SOAP message
Attachments attachments = ... // an Axiom attachment instance with some
attachments in it
OMOutputFormat format = new OMOutputFormat();
format.setCharSetEncoding(message.getCharsetEncoding());
format.setSOAP11(true);
format.setDoingSWA(true);
StringWriter writer = new StringWriter();
axiomMessage.getSOAPEnvelope().serialize(writer, format);
MIMEOutputUtils.writeSOAPWithAttachmentsMessage(writer, outputStream,
attachments, format);

Ignoring for a moment the hoops I have to jump through (writing the message
to a StringWriter ?!?), running this code will give me the following
stacktrace:

java.io.IOException: Invalid content type "text/xml; charset=UTF-8" for
XmlDCH
      at
com .sun .xml .internal .messaging .saaj.soap.XmlDataContentHandler.writeTo(XmlDataContentHandler.java: 106)
      at
javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java: 868)
      at javax.activation.DataHandler.writeTo(DataHandler.java:301)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java: 452)
      at
org .apache .axiom.om.impl.MIMEOutputUtils.writeBodyPart(MIMEOutputUtils.java: 245)
      at
org .apache .axiom .om .impl .MIMEOutputUtils .writeSOAPWithAttachmentsMessage(MIMEOutputUtils.java:283)
      ... 33 more

This is on Mac OS X, JDK 1.6.

After some decompiling of the JDK, it seems to be related to the built in
DataHandler for XML not being able to handle the charset part of the
content-type; it can only handle the exact strings "text/xml" or
"application/xml". Wrong, I know, but since I don't have commit- access to
the JDK I am more-or-less stuck with it as is.

Am I doing something wrong, or should I file a JIRA for this?

Thanks,

Arjen
---
Arjen Poutsma
Senior Software Engineer, SpringSource
Spring Web Services Lead
E: [EMAIL PROTECTED]
W: www.springsource.com
B: blog.springsource.com/arjen








--
Thilina Gunarathne - http://thilinag.blogspot.com

Reply via email to