LowCool
LowCool

Reputation: 1411

apache camel simple expression not giving string value

I am using apache camel. I am trying to retrieve value from body using simple expression language. I need it as a String but simple returns SimpleBuilder object. So I have tried something like this

simple("${body.address.line}").resultType(String.class).getResultType()

but it is returning me java.lang.String. please tell me how can I get this expression's result as String?

Upvotes: 3

Views: 7037

Answers (3)

Leponzo
Leponzo

Reputation: 656

I got error 'this' is not available following this answer with Camel 4.9.0, so I had to use the below:

exchange.getContext().resolveLanguage("simple").createExpression("${body.address.line}").evaluate(exchange, String.class)

Upvotes: 0

KayV
KayV

Reputation: 13855

Using xml, we can simply evaluate using

<simple>${body.address.line}</simple>

Upvotes: 1

Claus Ibsen
Claus Ibsen

Reputation: 55540

That is only for configuring the simple expression. If you need to evaluate it then call the evaluate method

String foo = simple("${body.address.line}").evaluate(exchange, String.class);

Upvotes: 4

Related Questions