Search in sources :

Example 1 with AttachmentEx

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);
    }
}
Also used : AttachmentEx(com.sun.xml.ws.api.message.AttachmentEx) Attachment(com.sun.xml.ws.api.message.Attachment) AttachmentPart(jakarta.xml.soap.AttachmentPart)

Aggregations

Attachment (com.sun.xml.ws.api.message.Attachment)1 AttachmentEx (com.sun.xml.ws.api.message.AttachmentEx)1 AttachmentPart (jakarta.xml.soap.AttachmentPart)1