You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Schneider Christian <Ch...@enbw.com> on 2010/02/03 11:53:06 UTC

Problem with headers of DefaultMessage being case insensitive

Hi all,

we are using camel and cxf to do SOAP/JMS. The other side is sometimes a
Tibco Business Works system. The problem there is that they use a non
standard header for SOAPAction. In Business works they expect it to be
spelled SoapAction. 

To work around this I have written an interceptor for CXF that adds a second
SoapAction header with the content of the SOAPAction header. 
see:
http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/ap
ache/cxf/binding/soap/interceptor/TibcoSoapActionInterceptor.java?view=marku
p

When we use the camel transport for cxf the message is the converted to a
camel message. The problem is that the properties of a camel message are not
case sensitive anymore. So only one of the headers is transfered.

So business works never gets the header it expects.

See the change in subversion:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache
/camel/impl/DefaultMessage.java?r1=630591&r2=893110&diff_format=h

Any idea how to solve this? I of course would perfer a solution that needs
no patch to camel.

With a patch I could imagine the following:
I thought I could perhaps add the second header in camel-jms. Perhaps this
could be switched on in the jms endpoint config.

Greetings

Christian


Christian Schneider
Team Handel und Risikomanagement
Informationsverarbeitung Business Solutions Trading
EnBW Systeme Infrastruktur Support GmbH

Informationsverarbeitung 
Business Solutions
Handel und Dispatching
Durlacher Allee 93
76131 Karlsruhe

Tel : +49-(0)721-63-15482
Mail: christian.schneider@enbw.com

Sitz der Gesellschaft: Karlsruhe
Handelsregister: Amtsgericht Mannheim   HRB 108550
Vorsitzender des Aufsichtsrats: Dr. Bernhard Beck
Geschäftsführer: Jochen Adenau, Dr. Peter Krampf


Re: Problem with headers of DefaultMessage being case insensitive

Posted by Christian Schneider <ch...@die-schneider.net>.
Hi Claus,

I even tried to  access the headers with reflection. This way I was able 
to get my headers into the message. The problem is only that in 
Pipeline.process() the exchange is copied
to a new exchange before the next step and the headers are then again 
wrapped in a case insensitive map.

I must also say that I don´t really understand what the case insensitive 
map should be good for. In any case it prevents people from having two 
headers that only differ in case. Which at least in my case is quite 
important as the receiving system is checking the case.

I will next try to create my own Message class which does not wrap ...

Greetings

Christian

Am 03.02.2010 21:56, schrieb Christian Schneider:
> Hi Claus,
>
> I don´t think this will work. DefaultMessage.setHeaders looks like 
> below. So the map I set will again be wrapped in a case insensitive map.
> Any other idea or should it still work?
>
> Greetings
>
> Christian
> ---
>
> public void setHeaders(Map<String, Object> headers) {
>         if (headers instanceof CaseInsensitiveMap) {
>             this.headers = headers;
>         } else {
>             // wrap it in a case insensitive map
>             this.headers = new CaseInsensitiveMap(headers);
>         }
>     }
>
> Am 03.02.2010 14:44, schrieb Claus Ibsen:
>> On Wed, Feb 3, 2010 at 11:53 AM, Schneider Christian
>> <Ch...@enbw.com>  wrote:
>>> Hi all,
>>>
>>> we are using camel and cxf to do SOAP/JMS. The other side is 
>>> sometimes a
>>> Tibco Business Works system. The problem there is that they use a non
>>> standard header for SOAPAction. In Business works they expect it to be
>>> spelled SoapAction.
>>>
>>> To work around this I have written an interceptor for CXF that adds 
>>> a second
>>> SoapAction header with the content of the SOAPAction header.
>>> see:
>>> http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/ap 
>>>
>>> ache/cxf/binding/soap/interceptor/TibcoSoapActionInterceptor.java?view=marku 
>>>
>>> p
>>>
>>> When we use the camel transport for cxf the message is the converted 
>>> to a
>>> camel message. The problem is that the properties of a camel message 
>>> are not
>>> case sensitive anymore. So only one of the headers is transfered.
>>>
>>> So business works never gets the header it expects.
>>>
>>> See the change in subversion:
>>> http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache 
>>>
>>> /camel/impl/DefaultMessage.java?r1=630591&r2=893110&diff_format=h
>>>
>>> Any idea how to solve this? I of course would perfer a solution that 
>>> needs
>>> no patch to camel.
>>>
>> You can use a interceptSendToEndpoint and use a Processor to set a new
>> Map as HashMap with the 2 soap actions
>>
>>
>>
>>> With a patch I could imagine the following:
>>> I thought I could perhaps add the second header in camel-jms. 
>>> Perhaps this
>>> could be switched on in the jms endpoint config.
>>>
>>> Greetings
>>>
>>> Christian
>>>
>>>
>>> Christian Schneider
>>> Team Handel und Risikomanagement
>>> Informationsverarbeitung Business Solutions Trading
>>> EnBW Systeme Infrastruktur Support GmbH
>>>
>>> Informationsverarbeitung
>>> Business Solutions
>>> Handel und Dispatching
>>> Durlacher Allee 93
>>> 76131 Karlsruhe
>>>
>>> Tel : +49-(0)721-63-15482
>>> Mail: christian.schneider@enbw.com
>>>
>>> Sitz der Gesellschaft: Karlsruhe
>>> Handelsregister: Amtsgericht Mannheim   HRB 108550
>>> Vorsitzender des Aufsichtsrats: Dr. Bernhard Beck
>>> Geschäftsführer: Jochen Adenau, Dr. Peter Krampf
>>>
>>>
>>
>>
>
>


-- 

Christian Schneider
---
http://www.liquid-reality.de


Re: Problem with headers of DefaultMessage being case insensitive

Posted by Christian Schneider <ch...@die-schneider.net>.
Hi Claus,

I don´t think this will work. DefaultMessage.setHeaders looks like 
below. So the map I set will again be wrapped in a case insensitive map.
Any other idea or should it still work?

Greetings

Christian
---

public void setHeaders(Map<String, Object> headers) {
         if (headers instanceof CaseInsensitiveMap) {
             this.headers = headers;
         } else {
             // wrap it in a case insensitive map
             this.headers = new CaseInsensitiveMap(headers);
         }
     }

Am 03.02.2010 14:44, schrieb Claus Ibsen:
> On Wed, Feb 3, 2010 at 11:53 AM, Schneider Christian
> <Ch...@enbw.com>  wrote:
>    
>> Hi all,
>>
>> we are using camel and cxf to do SOAP/JMS. The other side is sometimes a
>> Tibco Business Works system. The problem there is that they use a non
>> standard header for SOAPAction. In Business works they expect it to be
>> spelled SoapAction.
>>
>> To work around this I have written an interceptor for CXF that adds a second
>> SoapAction header with the content of the SOAPAction header.
>> see:
>> http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/ap
>> ache/cxf/binding/soap/interceptor/TibcoSoapActionInterceptor.java?view=marku
>> p
>>
>> When we use the camel transport for cxf the message is the converted to a
>> camel message. The problem is that the properties of a camel message are not
>> case sensitive anymore. So only one of the headers is transfered.
>>
>> So business works never gets the header it expects.
>>
>> See the change in subversion:
>> http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache
>> /camel/impl/DefaultMessage.java?r1=630591&r2=893110&diff_format=h
>>
>> Any idea how to solve this? I of course would perfer a solution that needs
>> no patch to camel.
>>
>>      
> You can use a interceptSendToEndpoint and use a Processor to set a new
> Map as HashMap with the 2 soap actions
>
>
>
>    
>> With a patch I could imagine the following:
>> I thought I could perhaps add the second header in camel-jms. Perhaps this
>> could be switched on in the jms endpoint config.
>>
>> Greetings
>>
>> Christian
>>
>>
>> Christian Schneider
>> Team Handel und Risikomanagement
>> Informationsverarbeitung Business Solutions Trading
>> EnBW Systeme Infrastruktur Support GmbH
>>
>> Informationsverarbeitung
>> Business Solutions
>> Handel und Dispatching
>> Durlacher Allee 93
>> 76131 Karlsruhe
>>
>> Tel : +49-(0)721-63-15482
>> Mail: christian.schneider@enbw.com
>>
>> Sitz der Gesellschaft: Karlsruhe
>> Handelsregister: Amtsgericht Mannheim   HRB 108550
>> Vorsitzender des Aufsichtsrats: Dr. Bernhard Beck
>> Geschäftsführer: Jochen Adenau, Dr. Peter Krampf
>>
>>
>>      
>
>
>    


-- 

Christian Schneider
---
http://www.liquid-reality.de


Re: Problem with headers of DefaultMessage being case insensitive

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Feb 3, 2010 at 11:53 AM, Schneider Christian
<Ch...@enbw.com> wrote:
> Hi all,
>
> we are using camel and cxf to do SOAP/JMS. The other side is sometimes a
> Tibco Business Works system. The problem there is that they use a non
> standard header for SOAPAction. In Business works they expect it to be
> spelled SoapAction.
>
> To work around this I have written an interceptor for CXF that adds a second
> SoapAction header with the content of the SOAPAction header.
> see:
> http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/ap
> ache/cxf/binding/soap/interceptor/TibcoSoapActionInterceptor.java?view=marku
> p
>
> When we use the camel transport for cxf the message is the converted to a
> camel message. The problem is that the properties of a camel message are not
> case sensitive anymore. So only one of the headers is transfered.
>
> So business works never gets the header it expects.
>
> See the change in subversion:
> http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache
> /camel/impl/DefaultMessage.java?r1=630591&r2=893110&diff_format=h
>
> Any idea how to solve this? I of course would perfer a solution that needs
> no patch to camel.
>

You can use a interceptSendToEndpoint and use a Processor to set a new
Map as HashMap with the 2 soap actions



> With a patch I could imagine the following:
> I thought I could perhaps add the second header in camel-jms. Perhaps this
> could be switched on in the jms endpoint config.
>
> Greetings
>
> Christian
>
>
> Christian Schneider
> Team Handel und Risikomanagement
> Informationsverarbeitung Business Solutions Trading
> EnBW Systeme Infrastruktur Support GmbH
>
> Informationsverarbeitung
> Business Solutions
> Handel und Dispatching
> Durlacher Allee 93
> 76131 Karlsruhe
>
> Tel : +49-(0)721-63-15482
> Mail: christian.schneider@enbw.com
>
> Sitz der Gesellschaft: Karlsruhe
> Handelsregister: Amtsgericht Mannheim   HRB 108550
> Vorsitzender des Aufsichtsrats: Dr. Bernhard Beck
> Geschäftsführer: Jochen Adenau, Dr. Peter Krampf
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Problem with headers of DefaultMessage being case insensitive

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Feb 4, 2010 at 7:42 AM, Christian Schneider
<ch...@die-schneider.net> wrote:
> Hi Claus,
>
> I will try this but I guess then a CXF server would be broken as it expects
> the uppercase version. I could of course only activate the processor if the
> receiver is a tibco system. As a workaround this would work but it would
> mean that we can not easily switch a service from a tibco to a cxf
> implementation or the
> other way.

Huh if you look at the test you can use the interceptors to only match
endpoints that is destinated for tibco.
I assume you can differentiate endpoints urls between CXF and Tibco!

See wiki doc for interceptors as it can use * and reg exp to match as well.


>
> Btw. I found another solution. It is not very nice but could work.  See
> below. I change the message directly before it is sent.
>

Yeah when its JMS you can do that and/or use the messageConverter
option to map to JMS yourself.


> Greetings
>
> Christian
>
> -----
>
> public class MyJmsTemplate extends CamelJmsTemplate {
>    public MyJmsTemplate(JmsConfiguration conf, ConnectionFactory
> connectionFactory) {
>        super(conf, connectionFactory);
>    }
>
>    @Override
>    protected void doSend(MessageProducer producer, Message message)
>            throws JMSException {
>        String soapAction = message.getStringProperty("SOAPAction");
>        message.setStringProperty("SoapAction", soapAction);
>        super.doSend(producer, message);
>    }
> }
>
> -----
>
> JmsComponent jms = JmsComponent.jmsComponent(new
> ActiveMQConnectionFactory());
>        jms.setJmsOperations(new MyJmsTemplate(jms.getConfiguration(),
> jms.getConfiguration().getTemplateConnectionFactory()));
>        myContext.addComponent("jms", jms);
>
>
>
> Am 04.02.2010 06:35, schrieb Claus Ibsen:
>>
>> On Wed, Feb 3, 2010 at 11:53 AM, Schneider Christian
>> <Ch...@enbw.com>  wrote:
>>
>>>
>>> Hi all,
>>>
>>> we are using camel and cxf to do SOAP/JMS. The other side is sometimes a
>>> Tibco Business Works system. The problem there is that they use a non
>>> standard header for SOAPAction. In Business works they expect it to be
>>> spelled SoapAction.
>>>
>>>
>>
>> Should SOAPAction and SoapAction contain the same value?
>> If so its easy to work around just remove the header and add it with
>> the case that Tibco want.
>>
>> See this test:
>> http://svn.apache.org/viewvc?rev=906371&view=rev
>>
>>
>>
>>>
>>> To work around this I have written an interceptor for CXF that adds a
>>> second
>>> SoapAction header with the content of the SOAPAction header.
>>> see:
>>>
>>> http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/ap
>>>
>>> ache/cxf/binding/soap/interceptor/TibcoSoapActionInterceptor.java?view=marku
>>> p
>>>
>>> When we use the camel transport for cxf the message is the converted to a
>>> camel message. The problem is that the properties of a camel message are
>>> not
>>> case sensitive anymore. So only one of the headers is transfered.
>>>
>>> So business works never gets the header it expects.
>>>
>>> See the change in subversion:
>>>
>>> http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache
>>> /camel/impl/DefaultMessage.java?r1=630591&r2=893110&diff_format=h
>>>
>>> Any idea how to solve this? I of course would perfer a solution that
>>> needs
>>> no patch to camel.
>>>
>>> With a patch I could imagine the following:
>>> I thought I could perhaps add the second header in camel-jms. Perhaps
>>> this
>>> could be switched on in the jms endpoint config.
>>>
>>> Greetings
>>>
>>> Christian
>>>
>>>
>>> Christian Schneider
>>> Team Handel und Risikomanagement
>>> Informationsverarbeitung Business Solutions Trading
>>> EnBW Systeme Infrastruktur Support GmbH
>>>
>>> Informationsverarbeitung
>>> Business Solutions
>>> Handel und Dispatching
>>> Durlacher Allee 93
>>> 76131 Karlsruhe
>>>
>>> Tel : +49-(0)721-63-15482
>>> Mail: christian.schneider@enbw.com
>>>
>>> Sitz der Gesellschaft: Karlsruhe
>>> Handelsregister: Amtsgericht Mannheim   HRB 108550
>>> Vorsitzender des Aufsichtsrats: Dr. Bernhard Beck
>>> Geschäftsführer: Jochen Adenau, Dr. Peter Krampf
>>>
>>>
>>>
>>
>>
>>
>
>
> --
>
> Christian Schneider
> ---
> http://www.liquid-reality.de
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Problem with headers of DefaultMessage being case insensitive

Posted by Christian Schneider <ch...@die-schneider.net>.
Hi Claus,

I will try this but I guess then a CXF server would be broken as it 
expects the uppercase version. I could of course only activate the 
processor if the
receiver is a tibco system. As a workaround this would work but it would 
mean that we can not easily switch a service from a tibco to a cxf 
implementation or the
other way.

Btw. I found another solution. It is not very nice but could work.  See 
below. I change the message directly before it is sent.

Greetings

Christian

-----

public class MyJmsTemplate extends CamelJmsTemplate {
     public MyJmsTemplate(JmsConfiguration conf, ConnectionFactory 
connectionFactory) {
         super(conf, connectionFactory);
     }

     @Override
     protected void doSend(MessageProducer producer, Message message)
             throws JMSException {
         String soapAction = message.getStringProperty("SOAPAction");
         message.setStringProperty("SoapAction", soapAction);
         super.doSend(producer, message);
     }
}

-----

JmsComponent jms = JmsComponent.jmsComponent(new 
ActiveMQConnectionFactory());
         jms.setJmsOperations(new MyJmsTemplate(jms.getConfiguration(), 
jms.getConfiguration().getTemplateConnectionFactory()));
         myContext.addComponent("jms", jms);



Am 04.02.2010 06:35, schrieb Claus Ibsen:
> On Wed, Feb 3, 2010 at 11:53 AM, Schneider Christian
> <Ch...@enbw.com>  wrote:
>    
>> Hi all,
>>
>> we are using camel and cxf to do SOAP/JMS. The other side is sometimes a
>> Tibco Business Works system. The problem there is that they use a non
>> standard header for SOAPAction. In Business works they expect it to be
>> spelled SoapAction.
>>
>>      
> Should SOAPAction and SoapAction contain the same value?
> If so its easy to work around just remove the header and add it with
> the case that Tibco want.
>
> See this test:
> http://svn.apache.org/viewvc?rev=906371&view=rev
>
>
>    
>> To work around this I have written an interceptor for CXF that adds a second
>> SoapAction header with the content of the SOAPAction header.
>> see:
>> http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/ap
>> ache/cxf/binding/soap/interceptor/TibcoSoapActionInterceptor.java?view=marku
>> p
>>
>> When we use the camel transport for cxf the message is the converted to a
>> camel message. The problem is that the properties of a camel message are not
>> case sensitive anymore. So only one of the headers is transfered.
>>
>> So business works never gets the header it expects.
>>
>> See the change in subversion:
>> http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache
>> /camel/impl/DefaultMessage.java?r1=630591&r2=893110&diff_format=h
>>
>> Any idea how to solve this? I of course would perfer a solution that needs
>> no patch to camel.
>>
>> With a patch I could imagine the following:
>> I thought I could perhaps add the second header in camel-jms. Perhaps this
>> could be switched on in the jms endpoint config.
>>
>> Greetings
>>
>> Christian
>>
>>
>> Christian Schneider
>> Team Handel und Risikomanagement
>> Informationsverarbeitung Business Solutions Trading
>> EnBW Systeme Infrastruktur Support GmbH
>>
>> Informationsverarbeitung
>> Business Solutions
>> Handel und Dispatching
>> Durlacher Allee 93
>> 76131 Karlsruhe
>>
>> Tel : +49-(0)721-63-15482
>> Mail: christian.schneider@enbw.com
>>
>> Sitz der Gesellschaft: Karlsruhe
>> Handelsregister: Amtsgericht Mannheim   HRB 108550
>> Vorsitzender des Aufsichtsrats: Dr. Bernhard Beck
>> Geschäftsführer: Jochen Adenau, Dr. Peter Krampf
>>
>>
>>      
>
>
>    


-- 

Christian Schneider
---
http://www.liquid-reality.de


Re: Problem with headers of DefaultMessage being case insensitive

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Feb 3, 2010 at 11:53 AM, Schneider Christian
<Ch...@enbw.com> wrote:
> Hi all,
>
> we are using camel and cxf to do SOAP/JMS. The other side is sometimes a
> Tibco Business Works system. The problem there is that they use a non
> standard header for SOAPAction. In Business works they expect it to be
> spelled SoapAction.
>

Should SOAPAction and SoapAction contain the same value?
If so its easy to work around just remove the header and add it with
the case that Tibco want.

See this test:
http://svn.apache.org/viewvc?rev=906371&view=rev


> To work around this I have written an interceptor for CXF that adds a second
> SoapAction header with the content of the SOAPAction header.
> see:
> http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/ap
> ache/cxf/binding/soap/interceptor/TibcoSoapActionInterceptor.java?view=marku
> p
>
> When we use the camel transport for cxf the message is the converted to a
> camel message. The problem is that the properties of a camel message are not
> case sensitive anymore. So only one of the headers is transfered.
>
> So business works never gets the header it expects.
>
> See the change in subversion:
> http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache
> /camel/impl/DefaultMessage.java?r1=630591&r2=893110&diff_format=h
>
> Any idea how to solve this? I of course would perfer a solution that needs
> no patch to camel.
>
> With a patch I could imagine the following:
> I thought I could perhaps add the second header in camel-jms. Perhaps this
> could be switched on in the jms endpoint config.
>
> Greetings
>
> Christian
>
>
> Christian Schneider
> Team Handel und Risikomanagement
> Informationsverarbeitung Business Solutions Trading
> EnBW Systeme Infrastruktur Support GmbH
>
> Informationsverarbeitung
> Business Solutions
> Handel und Dispatching
> Durlacher Allee 93
> 76131 Karlsruhe
>
> Tel : +49-(0)721-63-15482
> Mail: christian.schneider@enbw.com
>
> Sitz der Gesellschaft: Karlsruhe
> Handelsregister: Amtsgericht Mannheim   HRB 108550
> Vorsitzender des Aufsichtsrats: Dr. Bernhard Beck
> Geschäftsführer: Jochen Adenau, Dr. Peter Krampf
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus