You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Michael McKibben <mm...@users.sourceforge.net> on 2002/08/26 17:42:13 UTC
Problems using SAAJ client api to send attachment...
Hello, I am hoping someone here can help me with a problem I am having
sending attachments with the javax.xml.soap.* api using axis beta3.
I have written a simple test client that sends a doc/lit style SOAP request
to my Axis service. The problem is, for some reason, the client request does
not get encoded as a mime multipart/related message. Using tcpmon I just see
the SOAP part of the message and no attachments, so obviously my service
never sees the attachment!
<example>
SOAPConnectionFactory scf = SOAPConnectionFactory.newInstance();
SOAPConnection connection = scf.createConnection();
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage message = mf.createMessage();
SOAPEnvelope se = message.getSOAPPart().getEnvelope();
SOAPBody body = se.getBody();
SOAPBodyElement operation =
body.addBodyElement(se.createName("sendAttachment", "tns",
"http://localhost:8080/axis/services/TestAttachments"));
SOAPElement element = operation.addChildElement(se.createName("source"));
AttachmentPart attachment = message.createAttachmentPart(new
DataHandler(application.getResource("/test.txt")));
message.addAttachmentPart(attachment);
element.addAttribute(se.createName("href"), "cid:" +
attachment.getContentId());
SOAPMessage sp = connection.call(message,
"http://localhost:8080/axis/services/TestAttachments");
</example>
Also another problem that I found in trying to debug this is that
SOAPMessage.getSOAPPart().getContent() returns a null Source object! Is this
a bug?
Interestingly, if I use SOAPMessage.writeTo(java.lang.System.out) I see a
properly encoded message on my debug output; however the message still gets
sent as a plain old soap request with no attachment.
Thanks in advance for any pointers!
--mike