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());
}
}
}
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);
}
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;
}
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;
}
Aggregations