Hi all,

Im using CXF and want to set some custom HTTP headers. I implemented a javax.xml.ws.handler.soap.SOAPHandler and accessed the SOAPMessageContext in the handleMessage method. But setting my custom header prevents something from setting the SOAPAction header. I realized, that at the time I access the headers map, there is no map yet. Thats why Im creating a new one and set my custom header to the map. Here is my code:

private void addTraceIdToHttpRequestHeader(SOAPMessageContext context) {
Object object = context.get(MessageContext.HTTP_REQUEST_HEADERS);

if (object != null) {
        if (object instanceof Map) {
                Map<String, List<String>> map = (Map) object;
map.put(ContextKeys.TRACEID_HEADER_PARAM, Arrays.asList(LoggerUtils.getTraceId()));
        } else {
logger.warn("not setting trace id into http request header. object for {} is of type '{}'",
                                MessageContext.HTTP_REQUEST_HEADERS, 
object.getClass());
        }
} else {
        Map<String, List<String>> map = new HashMap<String, List<String>>();
map.put(ContextKeys.TRACEID_HEADER_PARAM, Arrays.asList(LoggerUtils.getTraceId()));
        context.put(MessageContext.HTTP_REQUEST_HEADERS, map);
}
}

This results in finding my custom http header in the request headers, but not the SOAPAction. If I remove my method, the SOAPAction is in the request.
Even this breaks setting the SOAPAction:

private void addTraceIdToHttpRequestHeader(SOAPMessageContext context) {
    context.put(MessageContext.HTTP_REQUEST_HEADERS, null);
}

Can anyone help me with this? Is this a CXF issue or is it an issue of an underlying framework/java? Or is it my fault?

Im using Websphere Liberty Profile and I think CXF 2.6.2. There are libs named "com.ibm.ws.org.apache.cxf-api.2.6.2_1.0.12.jar"

Greetings


Reply via email to