This was one of the earlier notes I wrote on this subject. Since this
time, I removed the dependence on DOMSource (the wrapper I was using for
the attachment), and instead serialized the XML to a string (using
xerces). However, once I did that, it fixed the servlet test case, but
then broke the Junit test case. Later, I tried changing the content
type of the attachment from "text/xml" to "text/plain", and that now
works in both the Junit and Cactus test cases. I fail to understand
exactly what is happening here, but I could use any information anyone
can give me about why either of these strategies fails, and why what I
did makes it work.
-----Original Message-----
From: Phil Goodwin [mailto:Phil.Goodwin_at_Sun.COM]
Sent: Friday, January 09, 2004 1:36 PM
To: users_at_saaj.dev.java.net
Subject: Re: [SAAJ-USR] SOAPMessage.writeTo(ByteArrayOutputStream) works
fine standalone, but fails from servlet
It looks like this message has some attachements that may be the cause
of the problem. It may be that the DataHandler that is configured to
handle the attachement is incorrect in the Servlet environment but
correct in the environment in which JUnit is being run. That would
certainly cause this problem.
Phil Goodwin
Karr, David wrote:
>I have a method which takes a SOAPMessage (actually ends up being
>"com.sun.xml.messaging.saaj.soap.ver1_1.Message1_1Impl"). The method
>creates a ByteArrayOutputStream and calls
>"SOAPMessage.writeTo(OutputStream)" to write the contents of the
>SOAPMessage as a string to the stream (I assume that's the intent of
>that).
>
>I wrote several Junit tests which end up calling this method, and they
>work perfectly fine.
>
>I now have a servlet which ends up calling the same method, and a
>Cactus test, with implicitly identical data to the Junit test, and when
>it gets to the "writeTo()" call in this method, I get the stack trace
>which follows this. I don't understand what is happening here.
>
>java.io.IOException: "text/xml" DataContentHandler requires String
>object, was given object of type class
javax.xml.transform.dom.DOMSource
> at com.sun.mail.handlers.text_plain.writeTo(text_plain.java:97)
> at
>javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:849)
> 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.jav
>a
>:563)
> at
>com.sun.xml.messaging.saaj.soap.MessageImpl.writeTo(MessageImpl.java:59
1
>)
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe_at_saaj.dev.java.net
>For additional commands, e-mail: users-help_at_saaj.dev.java.net
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_saaj.dev.java.net
For additional commands, e-mail: users-help_at_saaj.dev.java.net