Search in sources :

Example 6 with AttachmentSet

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

use of com.sun.xml.ws.api.message.AttachmentSet 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 8 with AttachmentSet

use of com.sun.xml.ws.api.message.AttachmentSet 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 9 with AttachmentSet

use of com.sun.xml.ws.api.message.AttachmentSet 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)9 AttachmentSet (com.sun.xml.ws.api.message.AttachmentSet)9 DataHandler (jakarta.activation.DataHandler)9 DataHandlerAttachment (com.sun.xml.ws.message.DataHandlerAttachment)6 Map (java.util.Map)4 HashMap (java.util.HashMap)3 WebServiceException (jakarta.xml.ws.WebServiceException)2 JavaCallInfo (com.oracle.webservices.api.databinding.JavaCallInfo)1 Databinding (com.sun.xml.ws.api.databinding.Databinding)1 DatabindingConfig (com.sun.xml.ws.api.databinding.DatabindingConfig)1 Packet (com.sun.xml.ws.api.message.Packet)1 WSDLPort (com.sun.xml.ws.api.model.wsdl.WSDLPort)1 SOAPMessageContextImpl (com.sun.xml.ws.handler.SOAPMessageContextImpl)1 CommandMap (jakarta.activation.CommandMap)1 MailcapCommandMap (jakarta.activation.MailcapCommandMap)1 WebServiceFeature (jakarta.xml.ws.WebServiceFeature)1 Image (java.awt.Image)1 Method (java.lang.reflect.Method)1 URL (java.net.URL)1 AbstractMap (java.util.AbstractMap)1