camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dunnlow <>
Subject Re: Set body to length of header string in Spring DSL?
Date Tue, 27 Nov 2012 17:33:55 GMT
Thanks, I have some reading up to do on OGNL (and file language).

To my initial question, sorry, I'm still not able to get my test working. 
Basically, nothing is output if I put a value in the name with the
expression you provided.  When I put a value in the name, I get the
following output depending on the contents of the Otherwise statement

Do you have any more insight as to the issue?  Here are some of the
expressions I tested and their results:

1) <camel:simple>${headerAs("name",String)}</camel:simple> 
       and also
      both output:  John

2) <camel:simple>${header("name").toString()}</camel:simple> 
        and also
     both output:  (nothing)

3) <camel:simple>${header("name")}</camel:simple>
    outputs: (nothing)

4) <camel:simple>${}</camel:simple>
   outputs:  John  

5)  <camel:javaScript>(request.headers.get('name')).length.toString()
   outputs:  function length() {/* int length() */}

6) <camel:groovy>'hello'.toString().length()</camel:groovy>
   outputs:  TypeConversionException (..."Error during type conversion from
type: java.lang.Integer to the requried typoe: byte[] with value 4 due to
java.lang.NoClassDefFoundError: org/apache/hadoop/hbase/util/Bytes....  at

7) <camel:groovy>'hello'.toString().length().toString()</camel:groovy>
    outputs: 5

my route:

       <camel:from uri="direct:t1">
                         <camel:constant>Is Null</camel:constant>
           <camel:to uri="stream:out"/>

my test code:

public class CamelStringTest extends CamelStringTestSupport {
   protected AbstractApplicationContext createApplicationContext() {
       return new ClassPathXmlApplicationContext("context.xml");

   public void testName() throws Exception {
    Map<String,Object> headers = new HashMap<String,Object>();
    template.sendBodyAndHeaders("direct:t1","Hello there",headers);

View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message