On Tue, Nov 27, 2012 at 4:14 AM, Willem jiang <willem.ji...@gmail.com> wrote:
> Hi,
>
> Does the header "name" value is String?
> If it is not , you'd better to convert it to a String.
>

Yeah it has to be a String so there is a length method. You can invoke
the toString method first.

<simple>${header("name").toString().length()}</simple>

Though there is also a headerAs function
<simple>${headerAs("name", String).length()}</simple>

The other scripting language should be able to do it as well. Though
you may have to invoke .toString() to ensure the value is a String
before calling the length method.



>
> --
> Willem Jiang
>
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Web: http://www.fusesource.com | http://www.redhat.com
> Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) 
> (English)
>           http://jnn.javaeye.com (http://jnn.javaeye.com/) (Chinese)
> Twitter: willemjiang
> Weibo: willemjiang
>
>
>
>
>
> On Tuesday, November 27, 2012 at 4:21 AM, dunnlow wrote:
>
>> (a simplification of an earlier question - I'm using camel 10.0, spring 3.1)
>>
>> Can someone tell me how, *using Spring DSL*, to set the message body to the
>> size of the message header named "name"? I don't care if it's simple, or a
>> different script language (I can't get any to work).
>>
>> Something like this -- but this doesn't work:
>>
>> <camel:setBody>
>>
>> <camel:javaScript>request.headers.get('name').length</camel:javaScript>
>> </camel:setBody>
>>
>> I am able to verify the header exists and stream it to standard out just
>> fine, but trying to get the length throws a variety of exceptions depending
>> on the method/language I try.
>>
>> Thanks very much!
>> -J
>>
>>
>>
>> --
>> View this message in context: 
>> http://camel.465427.n5.nabble.com/Set-body-to-length-of-header-string-in-Spring-DSL-tp5723258.html
>> Sent from the Camel - Users mailing list archive at Nabble.com 
>> (http://Nabble.com).
>
>
>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cib...@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Reply via email to