Hi

that is good, thanks for getting to the bottom of it, must be an easy fix, IMHO we will just need to remove 'else', in a regular CXF request, CONTENT_TYPE is available on the message as a dedicated property & also part of the headers map.

Would you like to attach a basic patch to that JIRA issue ? It is your fix after all, I'll edit the JIRA description later (I thought the headers were blocked which is where I was wrong)

Thanks, Sergey

On 16/10/13 18:51, Amit wrote:
After removing conent-type from header filter. I found the issue in
CxfHeaderHelper below method. It puts the content Type in message not in
header and org.apache.cxf.jaxrs.impl.HttpHeadersImpl class get  content Type
from header. I did comment out "if
(Exchange.CONTENT_TYPE.equals(entry.getKey()))"  block and it works as
expected.



public static void propagateCamelToCxf(HeaderFilterStrategy strategy,
             Map<String, Object> headers, Message message, Exchange exchange)
{

         Map<String, List&lt;String>> cxfHeaders =
             CastUtils.cast((Map<?,
?>)message.get(Message.PROTOCOL_HEADERS));

         if (cxfHeaders == null) {
             // use a treemap to keep ordering and ignore key case
             cxfHeaders = new TreeMap<String,
List&lt;String>>(String.CASE_INSENSITIVE_ORDER);
             message.put(Message.PROTOCOL_HEADERS, cxfHeaders);
         }

         for (Map.Entry<String, Object> entry : headers.entrySet()) {
             if (strategy != null
                     && !strategy.applyFilterToCamelHeaders(entry.getKey(),
entry.getValue(), exchange)) {

                 if (Exchange.CONTENT_TYPE.equals(entry.getKey())) {
//commented out this block
                     message.put(Message.CONTENT_TYPE, entry.getValue());
                 } else
                        
                 if (Client.REQUEST_CONTEXT.equals(entry.getKey())
                             ||
Client.RESPONSE_CONTEXT.equals(entry.getKey())
                             || Message.RESPONSE_CODE.equals(entry.getKey()))
{
                     message.put(entry.getKey(), entry.getValue());
                 } else {
                     Object values = entry.getValue();
                     if (values instanceof List<?>) {
                         cxfHeaders.put(entry.getKey(),
CastUtils.cast((List<?>)values, String.class));
                     } else {
                         List<String> listValue = new ArrayList<String>();
                         listValue.add(entry.getValue().toString());
                         cxfHeaders.put(entry.getKey(), listValue);
                     }
                 }
             }
         }
     }

Thanks,
Amit



--
View this message in context: 
http://camel.465427.n5.nabble.com/CFX-Bean-headers-access-Issue-tp5741312p5741691.html
Sent from the Camel - Users mailing list archive at Nabble.com.



--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Reply via email to