Announcement Announcement Module
No announcement yet.
Attachments Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Attachments

    I am successfully sending an image like this:
    SOAPMessage message = messageFactory.createMessage();
    SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
    Name transferFileRequestName = envelope.createName(
    "transferFileRequest", PREFIX, NAMESPACE_URI);

    message.getSOAPBody().addBodyElement(transferFileR equestName);

    // IMAGE
    URL url = new URL("file:///temp/mrudulu.jpg");
    DataHandler dataHandler = new DataHandler(url);
    AttachmentPart ap2 = message.createAttachmentPart(dataHandler);

    message.addAttachmentPart(ap2); // message is SOAPMessage

    return message;

    However, I can not extract the attachment on the other side:

    protected Object invokeInternal(Object requestObject) throws Exception {
    TransferFileRequest request = (TransferFileRequest) requestObject;
    List list = request.getContent();
    Iterator it = list.iterator();
    while(it.hasNext()) {
    Object obj =;
    System.out.println(obj.getClass().getName()+" "+obj.toString());
    return null;

    I am only getting 1 empty string. Am I using the right API? What do I do wrong?


  • #2
    It seems like you are extending the AbstractMarshallingPayloadEndpoint, is that correct?

    That endpoint only focusses on contents of the message, not the attachments. You can get the full message by implementing messageEndpoint, and doing a messageContext.getRequest(), which can be casted to a SoapMessage that contains the attachment.