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

  • Attachments

    Hi
    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 = it.next();
    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?

    Thanks.

  • #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.

    Comment

    Working...
    X