Search in sources :

Example 1 with MimeHeader

use of jakarta.xml.soap.MimeHeader in project openmq by eclipse-ee4j.

the class UMSServlet method putHeaders.

/**
 * Sets the given <code>HttpServletResponse</code> object with the headers in the given <code>MimeHeaders</code> object.
 *
 * @param headers the <code>MimeHeaders</code> object containing the the headers in the message sent to the servlet
 * @param res the <code>HttpServletResponse</code> object to which the headers are to be written
 * @see #getHeaders
 */
protected static void putHeaders(MimeHeaders headers, HttpServletResponse res) {
    Iterator it = headers.getAllHeaders();
    while (it.hasNext()) {
        MimeHeader header = (MimeHeader) it.next();
        String[] values = headers.getHeader(header.getName());
        if (values.length == 1) {
            res.setHeader(header.getName(), header.getValue());
        } else {
            StringBuilder concat = new StringBuilder();
            int i = 0;
            while (i < values.length) {
                if (i != 0) {
                    concat.append(',');
                }
                concat.append(values[i++]);
            }
            res.setHeader(header.getName(), concat.toString());
        }
    }
}
Also used : MimeHeader(jakarta.xml.soap.MimeHeader) Iterator(java.util.Iterator)

Example 2 with MimeHeader

use of jakarta.xml.soap.MimeHeader in project metro-jax-ws by eclipse-ee4j.

the class SAAJFactoryTest method testDuplicatedContentID.

public void testDuplicatedContentID() throws Exception {
    String ctype = "multipart/related; boundary=MIME_Boundary; " + "start=\"<6232425701115978772--54bee05.140acdf4f8a.-7f3f>\"; " + "type=\"text/xml\"; start-info=\"text/xml\"";
    InputStream is = getClass().getClassLoader().getResourceAsStream("etc/bug17367334InputMsg.txt");
    MessageContextFactory mcf = MessageContextFactory.createFactory();
    Packet packet = (Packet) mcf.createContext(is, ctype);
    Message message = packet.getInternalMessage();
    SAAJFactory factory = new SAAJFactory();
    SOAPMessage saajMessage = factory.readAsSOAPMessage(SOAPVersion.SOAP_11, message);
    AttachmentPart ap = (AttachmentPart) saajMessage.getAttachments().next();
    Iterator it = ap.getAllMimeHeaders();
    int countContentID = 0;
    while (it.hasNext()) {
        MimeHeader mh = (MimeHeader) it.next();
        if ("Content-Id".equalsIgnoreCase(mh.getName())) {
            countContentID++;
        }
    }
    assertEquals("More than one Content-Id", 1, countContentID);
}
Also used : Packet(com.sun.xml.ws.api.message.Packet) Message(com.sun.xml.ws.api.message.Message) SOAPMessage(jakarta.xml.soap.SOAPMessage) StreamMessage(com.sun.xml.ws.message.stream.StreamMessage) MessageContextFactory(com.oracle.webservices.api.message.MessageContextFactory) SAAJFactory(com.sun.xml.ws.api.message.saaj.SAAJFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) MimeHeader(jakarta.xml.soap.MimeHeader) Iterator(java.util.Iterator) AttachmentPart(jakarta.xml.soap.AttachmentPart) SOAPMessage(jakarta.xml.soap.SOAPMessage)

Example 3 with MimeHeader

use of jakarta.xml.soap.MimeHeader in project metro-jax-ws by eclipse-ee4j.

the class SOAPMessageDispatch method createPacket.

@Override
Packet createPacket(SOAPMessage arg) {
    Iterator iter = arg.getMimeHeaders().getAllHeaders();
    Headers ch = new Headers();
    while (iter.hasNext()) {
        MimeHeader mh = (MimeHeader) iter.next();
        ch.add(mh.getName(), mh.getValue());
    }
    Packet packet = new Packet(SAAJFactory.create(arg));
    packet.invocationProperties.put(MessageContext.HTTP_REQUEST_HEADERS, ch);
    return packet;
}
Also used : Packet(com.sun.xml.ws.api.message.Packet) Headers(com.sun.xml.ws.transport.Headers) MimeHeader(jakarta.xml.soap.MimeHeader) Iterator(java.util.Iterator)

Example 4 with MimeHeader

use of jakarta.xml.soap.MimeHeader in project metro-jax-ws by eclipse-ee4j.

the class MessageContextFactory method toMap.

static Map<String, List<String>> toMap(MimeHeaders headers) {
    HashMap<String, List<String>> map = new HashMap<>();
    for (Iterator<MimeHeader> i = headers.getAllHeaders(); i.hasNext(); ) {
        MimeHeader mh = i.next();
        List<String> values = map.computeIfAbsent(mh.getName(), k -> new ArrayList<>());
        values.add(mh.getValue());
    }
    return map;
}
Also used : HashMap(java.util.HashMap) MimeHeader(jakarta.xml.soap.MimeHeader) ArrayList(java.util.ArrayList) List(java.util.List) WSFeatureList(com.sun.xml.ws.api.WSFeatureList)

Aggregations

MimeHeader (jakarta.xml.soap.MimeHeader)4 Iterator (java.util.Iterator)3 Packet (com.sun.xml.ws.api.message.Packet)2 MessageContextFactory (com.oracle.webservices.api.message.MessageContextFactory)1 WSFeatureList (com.sun.xml.ws.api.WSFeatureList)1 Message (com.sun.xml.ws.api.message.Message)1 SAAJFactory (com.sun.xml.ws.api.message.saaj.SAAJFactory)1 StreamMessage (com.sun.xml.ws.message.stream.StreamMessage)1 Headers (com.sun.xml.ws.transport.Headers)1 AttachmentPart (jakarta.xml.soap.AttachmentPart)1 SOAPMessage (jakarta.xml.soap.SOAPMessage)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1