users@saaj.java.net

Re: [SAAJ-USR] R: [SAAJ-USR] New Issue in XmlDataContentHandler

From: V B Kumar Jayanti <Vbkumar.Jayanti_at_Sun.COM>
Date: Mon, 21 Jul 2008 17:47:38 +0530

Thanks a lot for the testcase. I will ask our QE to incorporate this as
a testcase.

regards.
kumar

Montebove Luciano wrote:

>Even if I encountered the problem using indirectly Axiom and SAAJ with Spring Web Services, here is a sample code reproducing the exception.
>The SAAJ libs are the July 5 night-build from here:
>https://saaj.dev.java.net/servlets/ProjectDocumentList?folderID=5118&expandFolder=5118&folderID=5118
>
>I wrote 2 SOAP client classes generating a message with an attachment:
>AxionClient using Axiom.
>SAAJClient using SAAJ.
>
>The Main class calls first the AxiomClient without any exception, then calls SAAJClient without any problem, but then (as SAAJ registered XmlDataContentHandler) the next call to the AxiomClient fails with:
>
>Exception in thread "main" org.apache.axiom.om.OMException: Error while writing to the OutputStream.
> at org.apache.axiom.om.impl.MIMEOutputUtils.writeSOAPWithAttachmentsMessage(MIMEOutputUtils.java:297)
> at AxiomClient.send(AxiomClient.java:78)
> at Main.main(Main.java:11)
>Caused by: java.io.IOException: Unable to run the JAXP transformer on a stream java.lang.String
> at com.sun.xml.messaging.saaj.soap.XmlDataContentHandler.writeTo(XmlDataContentHandler.java:151)
> at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:897)
> at javax.activation.DataHandler.writeTo(DataHandler.java:330)
> at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1403)
> at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:874)
> at org.apache.axiom.om.impl.MIMEOutputUtils.writeBodyPart(MIMEOutputUtils.java:245)
> at org.apache.axiom.om.impl.MIMEOutputUtils.writeSOAPWithAttachmentsMessage(MIMEOutputUtils.java:283)
>
>where the real Exception masked from XmlDataContentHandler is the ClassCastException I talked about in my previous post.
>
>Thanks
>
>Luciano
>
>-----Messaggio originale-----
>Da: V B Kumar Jayanti [mailto:Vbkumar.Jayanti_at_Sun.COM]
>Inviato: luned́ 21 luglio 2008 8.32
>A: users_at_saaj.dev.java.net
>Oggetto: Re: [SAAJ-USR] New Issue in XmlDataContentHandler
>
>Montebove Luciano wrote:
>
>
>
>>I don't' know if it is anohter bug in
>>com.sun.xml.messaging.saaj.soap.XmlDataContentHandler, specifically
>>the writeTo method.
>>
>>When I mix in the same JVM (Java 5) Axiom Swa and SAAJ MTOM I first
>>encountered the problem referred here
>>https://saaj.dev.java.net/servlets/ReadMsg?list=users&msgNo=83.
>>After downloading the saaj patched version from here
>>https://saaj.dev.java.net/servlets/ProjectDocumentList?folderID=5118&exp
>>andFolder=5118&folderID=5118
>>I solved this problem, but then when I use an Axiom SwA web service
>>client after using SAAJ I got this new error:
>>java.io.IOException: Unable to run the JAXP transformer on a stream
>>java.lang.String
>>23:09:25,187 ERROR [STDERR] at
>>com.sun.xml.messaging.saaj.soap.XmlDataContentHandler.writeTo....
>>
>>After some debugging I discovered the problem is the casting of the
>>Object to write to javax.xml.transform.Source (last line of following
>>coe fragment from XmlDataContentHandler):
>>....
>>if (obj instanceof DataSource) {
>>// Streaming transform applies only to javax.xml.transform.StreamSource
>> transformer.transform((Source) getContent((DataSource)obj), result);
>>
>> }
>> else {
>> transformer.transform((Source) obj, result);
>> }
>>....
>>
>>the real Exception is a ClassCastException because obj is a String.
>>I don't know if the Axiom way to create the MimePart content as a String
>>is correct but a simple change to the previous lines in
>>XmlDataContentHandler solves the problem:
>> if (obj instanceof DataSource) {
>> // Streaming transform applies only to
>>javax.xml.transform.StreamSource
>> transformer.transform((Source)
>>getContent((DataSource) obj),
>> result);
>> } else {
>> Source src=null;
>> if (obj instanceof String) {
>> src= new StreamSource(new
>>java.io.StringReader((String) obj));
>> } else
>> src=(Source) obj;
>> transformer.transform(src, result);
>> }
>>
>>
>>
>>
>>
>If you can provide me a small testcase to reproduce this problem then i
>think i should definitely integrate the kind of fix that you are suggesting.
>
>Thanks,
>kumar
>
>
>
>>---------------------------------------------------------------------
>>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
>
>