Results 1 to 2 of 2

Thread: Attachments

  1. #1
    Join Date
    Dec 2005
    Location
    California
    Posts
    63

    Default 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.
    Janos

  2. #2
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    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.
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •