Hi,
I have a strange error when I try to attach an XML document to the SOAPMessageContext
and don't know if Axis API 1.3 are involved in this.
Here's my code:
SOAPMessageContext soapmcontext = (SOAPMessageContext) mc;
String test ="<test></test>";
SOAPMessage soapmessage = soapmcontext.getMessage();
StreamSource source = new StreamSource(new StringReader(test);
DataHandler dh = new DataHandler(source,"text/xml");
AttachmentPart attachment = soapmessage.createAttachmentPart(dh);
attachment.setDataHandler(dh);
soapmessage.addAttachmentPart(attachment);
and here's what i get:
java.io.IOException: "text/xml" DataContentHandler requires String
object, was given object of type class
javax.xml.transform.stream.StreamSource
at com.sun.mail.handlers.text_plain.writeTo(text_plain.java:103)
(see the complete stack trace below)
It's strange because the error message says exactly the opposite of JAX-RPC specs:
the "text/xml" mime type is sppusosed to be mapped to javax.xml.transform.stream.StreamSource
If i replace the line
DataHandler dh = new DataHandler(source,"text/xml");
with:
DataHandler dh = new DataHandler(test,"text/xml");
it works !
Thanks for your help
java.io.IOException: "text/xml" DataContentHandler requires String
object, was given object of type class
javax.xml.transform.stream.StreamSource
at com.sun.mail.handlers.text_plain.writeTo(text_plain.java:103)
at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:839)
at javax.activation.DataHandler.writeTo(DataHandler.java:295)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1201)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:707)
at javax.mail.internet.MimeMultipart.writeTo(MimeMultipart.java:233)
at com.sun.mail.handlers.multipart_mixed.writeTo(multipart_mixed.java:67)
at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:839)
at javax.activation.DataHandler.writeTo(DataHandler.java:295)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1201)
at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1611)
at org.apache.axis.attachments.MimeUtils.writeToMultiPartStream(MimeUtils.java:202)
at org.apache.axis.attachments.AttachmentsImpl.writeContentToStream(AttachmentsImpl.java:493)
at org.apache.axis.Message.writeTo(Message.java:545)
at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:511)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at com.test.infra.ws.InsuranceMsgSvcCallBindingStub.call(AcordMsgSvcCallBindingStub.java:933)
at com.test.infra.ws.StubTestCallWS.testWithSingleXMLAttachment(StubTestCallWS.java:156)
