Has anyone used Axis for sending attachments (in Messaging mode, not RPC) across?
 
The following chunk of code does not seem to work. When the message reaches the server, there are no attachments with it. What am I doing wrong? Also a side question. Does Axis fully support JAXM?
 
=============================================
 

SOAPConnectionFactory simpl = SOAPConnectionFactory.newInstance();

SOAPConnection conn = simpl.createConnection();

try {

    MessageFactory mf = MessageFactory.newInstance();

    SOAPMessage sm = mf.createMessage();

    SOAPPart soapPart = sm.getSOAPPart();

    SOAPEnvelope envelope = soapPart.getEnvelope();

    SOAPHeader header = envelope.getHeader();

    SOAPBody body = envelope.getBody();

    URLEndpoint urle = new URLEndpoint(options.getURL());

    Name bodyName = envelope.createName("ServiceMethod", "", "urn:Attachment");

    javax.xml.soap.SOAPBodyElement gltp = body.addBodyElement(bodyName);

    // Add an attachment (binary attachment)

    URL url2 = new File("C:\\foo.class").toURL();

    AttachmentPart ap2 = sm.createAttachmentPart(new DataHandler(url2));

    ap2.setContentType("image");

    sm.addAttachmentPart(ap2);

    sm.saveChanges();

    SOAPMessage result = conn.call(sm, (Object)urle);

} catch (Exception e) {

    e.printStackTrace();

}

=================================================
 
 
 
Thanks in Advance
 
Sundar 

Reply via email to