-
Oct 27th, 2006, 03:52 PM
#1
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
-
Oct 29th, 2006, 03:18 PM
#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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules