Search in sources :

Example 11 with Attachment

use of com.sun.xml.ws.api.message.Attachment in project metro-jax-ws by eclipse-ee4j.

the class ClientSOAPHandlerTube method callHandlersOnRequest.

boolean callHandlersOnRequest(MessageUpdatableContext context, boolean isOneWay) {
    boolean handlerResult;
    // Lets copy all the MessageContext.OUTBOUND_ATTACHMENT_PROPERTY to the message
    Map<String, DataHandler> atts = (Map<String, DataHandler>) context.get(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS);
    AttachmentSet attSet = context.packet.getMessage().getAttachments();
    for (Entry<String, DataHandler> entry : atts.entrySet()) {
        String cid = entry.getKey();
        if (attSet.get(cid) == null) {
            // Otherwise we would be adding attachments twice
            Attachment att = new DataHandlerAttachment(cid, atts.get(cid));
            attSet.add(att);
        }
    }
    try {
        // CLIENT-SIDE
        handlerResult = processor.callHandlersRequest(HandlerProcessor.Direction.OUTBOUND, context, !isOneWay);
    } catch (WebServiceException wse) {
        remedyActionTaken = true;
        // no rewrapping
        throw wse;
    } catch (RuntimeException re) {
        remedyActionTaken = true;
        throw new WebServiceException(re);
    }
    if (!handlerResult) {
        remedyActionTaken = true;
    }
    return handlerResult;
}
Also used : AttachmentSet(com.sun.xml.ws.api.message.AttachmentSet) DataHandlerAttachment(com.sun.xml.ws.message.DataHandlerAttachment) WebServiceException(jakarta.xml.ws.WebServiceException) DataHandlerAttachment(com.sun.xml.ws.message.DataHandlerAttachment) Attachment(com.sun.xml.ws.api.message.Attachment) DataHandler(jakarta.activation.DataHandler)

Example 12 with Attachment

use of com.sun.xml.ws.api.message.Attachment in project metro-jax-ws by eclipse-ee4j.

the class ServerSOAPHandlerTube method callHandlersOnResponse.

void callHandlersOnResponse(MessageUpdatableContext context, boolean handleFault) {
    // Lets copy all the MessageContext.OUTBOUND_ATTACHMENT_PROPERTY to the message
    Map<String, DataHandler> atts = (Map<String, DataHandler>) context.get(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS);
    AttachmentSet attSet = context.packet.getMessage().getAttachments();
    for (Map.Entry<String, DataHandler> entry : atts.entrySet()) {
        String cid = entry.getKey();
        if (attSet.get(cid) == null) {
            // Otherwise we would be adding attachments twice
            Attachment att = new DataHandlerAttachment(cid, atts.get(cid));
            attSet.add(att);
        }
    }
    try {
        // SERVER-SIDE
        processor.callHandlersResponse(HandlerProcessor.Direction.OUTBOUND, context, handleFault);
    } catch (RuntimeException wse) {
        // no rewrapping
        throw wse;
    }
}
Also used : AttachmentSet(com.sun.xml.ws.api.message.AttachmentSet) DataHandlerAttachment(com.sun.xml.ws.message.DataHandlerAttachment) DataHandlerAttachment(com.sun.xml.ws.message.DataHandlerAttachment) Attachment(com.sun.xml.ws.api.message.Attachment) DataHandler(jakarta.activation.DataHandler)

Example 13 with Attachment

use of com.sun.xml.ws.api.message.Attachment 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)

Example 14 with Attachment

use of com.sun.xml.ws.api.message.Attachment in project metro-jax-ws by eclipse-ee4j.

the class MimeAttachmentSet method get.

@Nullable
public Attachment get(String contentId) {
    Attachment att;
    /*
          First try to get the Attachment from internal map, maybe this attachment
          is added by the user.
         */
    att = atts.get(contentId);
    if (att != null)
        return att;
    try {
        /*
              Attachment is not found in the internal map, now do look in
              the mpp, if found add to the internal Attachment map.
             */
        att = mpp.getAttachmentPart(contentId);
        if (att != null) {
            atts.put(contentId, att);
        }
    } catch (IOException e) {
        throw new WebServiceException(EncodingMessages.NO_SUCH_CONTENT_ID(contentId), e);
    }
    return att;
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) Attachment(com.sun.xml.ws.api.message.Attachment) IOException(java.io.IOException) Nullable(com.sun.istack.Nullable)

Example 15 with Attachment

use of com.sun.xml.ws.api.message.Attachment in project metro-jax-ws by eclipse-ee4j.

the class AttachmentMarshallerImpl method addSwaRefAttachment.

@Override
public String addSwaRefAttachment(DataHandler data) {
    String cid = encodeCid(null);
    Attachment att = new DataHandlerAttachment(cid, data);
    attachments.add(att);
    cid = "cid:" + cid;
    return cid;
}
Also used : DataHandlerAttachment(com.sun.xml.ws.message.DataHandlerAttachment) DataHandlerAttachment(com.sun.xml.ws.message.DataHandlerAttachment) Attachment(com.sun.xml.ws.api.message.Attachment)

Aggregations

Attachment (com.sun.xml.ws.api.message.Attachment)20 DataHandler (jakarta.activation.DataHandler)12 AttachmentSet (com.sun.xml.ws.api.message.AttachmentSet)9 DataHandlerAttachment (com.sun.xml.ws.message.DataHandlerAttachment)8 Map (java.util.Map)7 HashMap (java.util.HashMap)5 Packet (com.sun.xml.ws.api.message.Packet)4 Message (com.sun.xml.ws.api.message.Message)3 StreamingDataHandler (com.sun.xml.ws.developer.StreamingDataHandler)3 WebServiceException (jakarta.xml.ws.WebServiceException)3 JavaCallInfo (com.oracle.webservices.api.databinding.JavaCallInfo)2 MessageContext (com.oracle.webservices.api.message.MessageContext)2 Nullable (com.sun.istack.Nullable)2 SOAPVersion (com.sun.xml.ws.api.SOAPVersion)2 Databinding (com.sun.xml.ws.api.databinding.Databinding)2 DatabindingConfig (com.sun.xml.ws.api.databinding.DatabindingConfig)2 WSDLPort (com.sun.xml.ws.api.model.wsdl.WSDLPort)2 Codec (com.sun.xml.ws.api.pipe.Codec)2 MIMEPartStreamingDataHandler (com.sun.xml.ws.encoding.MIMEPartStreamingDataHandler)2 SOAPMessageContextImpl (com.sun.xml.ws.handler.SOAPMessageContextImpl)2