use of com.sun.xml.ws.api.message.AttachmentEx in project metro-jax-ws by eclipse-ee4j.
the class SAAJFactory method addAttachmentsToSOAPMessage.
protected static void addAttachmentsToSOAPMessage(SOAPMessage msg, Message message) {
for (Attachment att : message.getAttachments()) {
AttachmentPart part = msg.createAttachmentPart();
part.setDataHandler(att.asDataHandler());
// Be safe and avoid double angle-brackets.
String cid = att.getContentId();
if (cid != null) {
if (cid.startsWith("<") && cid.endsWith(">"))
part.setContentId(cid);
else
part.setContentId('<' + cid + '>');
}
// by the DataHandler above.
if (att instanceof AttachmentEx) {
AttachmentEx ax = (AttachmentEx) att;
Iterator<AttachmentEx.MimeHeader> imh = ax.getMimeHeaders();
while (imh.hasNext()) {
AttachmentEx.MimeHeader ame = imh.next();
if ((!"Content-ID".equalsIgnoreCase(ame.getName())) && (!"Content-Type".equalsIgnoreCase(ame.getName())))
part.addMimeHeader(ame.getName(), ame.getValue());
}
}
msg.addAttachmentPart(part);
}
}
Aggregations