Search in sources :

Example 16 with Attachment

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

the class ServerMessageHandlerTube 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 (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 17 with Attachment

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

the class MessageContextImpl method get.

public Object get(Object key) {
    if (key == null)
        return null;
    Object value = asMapIncludingInvocationProperties.get(key);
    // add the attachments from the Message to the corresponding attachment property
    if (key.equals(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS) || key.equals(MessageContext.INBOUND_MESSAGE_ATTACHMENTS)) {
        Map<String, DataHandler> atts = (Map<String, DataHandler>) value;
        if (atts == null)
            atts = new HashMap<>();
        AttachmentSet attSet = packet.getMessage().getAttachments();
        for (Attachment att : attSet) {
            String cid = att.getContentId();
            if (!cid.contains("@jaxws.sun.com")) {
                Object a = atts.get(cid);
                if (a == null) {
                    a = atts.get("<" + cid + ">");
                    if (a == null)
                        atts.put(att.getContentId(), att.asDataHandler());
                }
            } else {
                atts.put(att.getContentId(), att.asDataHandler());
            }
        }
        return atts;
    }
    return value;
}
Also used : AttachmentSet(com.sun.xml.ws.api.message.AttachmentSet) HashMap(java.util.HashMap) Attachment(com.sun.xml.ws.api.message.Attachment) DataHandler(jakarta.activation.DataHandler) Map(java.util.Map) HashMap(java.util.HashMap)

Example 18 with Attachment

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

the class ServerLogicalHandlerTube 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 (Entry<String, DataHandler> entry : atts.entrySet()) {
        String cid = entry.getKey();
        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) Map(java.util.Map)

Example 19 with Attachment

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

the class DispatchImpl method setOutboundAttachments.

protected AttachmentSet setOutboundAttachments() {
    HashMap<String, DataHandler> attachments = (HashMap<String, DataHandler>) getRequestContext().get(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS);
    if (attachments != null) {
        List<Attachment> alist = new ArrayList();
        for (Map.Entry<String, DataHandler> att : attachments.entrySet()) {
            DataHandlerAttachment dha = new DataHandlerAttachment(att.getKey(), att.getValue());
            alist.add(dha);
        }
        return new AttachmentSetImpl(alist);
    }
    return new AttachmentSetImpl();
}
Also used : DataHandlerAttachment(com.sun.xml.ws.message.DataHandlerAttachment) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) DataHandlerAttachment(com.sun.xml.ws.message.DataHandlerAttachment) Attachment(com.sun.xml.ws.api.message.Attachment) DataHandler(jakarta.activation.DataHandler) AttachmentSetImpl(com.sun.xml.ws.message.AttachmentSetImpl) Map(java.util.Map) HashMap(java.util.HashMap)

Example 20 with Attachment

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

the class ResponseContext method get.

public Object get(Object key) {
    if (packet.supports(key))
        // strongly typed
        return packet.get(key);
    if (packet.getHandlerScopePropertyNames(true).contains(key))
        // no such application-scope property
        return null;
    Object value = packet.invocationProperties.get(key);
    // add the attachments from the Message to the corresponding attachment property
    if (key.equals(MessageContext.INBOUND_MESSAGE_ATTACHMENTS)) {
        Map<String, DataHandler> atts = (Map<String, DataHandler>) value;
        if (atts == null)
            atts = new HashMap<>();
        AttachmentSet attSet = packet.getMessage().getAttachments();
        for (Attachment att : attSet) {
            atts.put(att.getContentId(), att.asDataHandler());
        }
        return atts;
    }
    return value;
}
Also used : AttachmentSet(com.sun.xml.ws.api.message.AttachmentSet) HashMap(java.util.HashMap) Attachment(com.sun.xml.ws.api.message.Attachment) DataHandler(jakarta.activation.DataHandler) AbstractMap(java.util.AbstractMap) Map(java.util.Map) HashMap(java.util.HashMap)

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