Maybe this helps
Jan
public class ArrayTest extends CamelTestSupport {
@EndpointInject(uri="mock:end")
MockEndpoint mockEndpoint;
@Test
public void stringArray() throws InterruptedException {
mockEndpoint.expectedMessageCount(1);
// Access to arry information
mockEndpoint.expectedHeaderReceived("length", 3);
// Access to array content
mockEndpoint.expectedHeaderReceived("first", "one");
mockEndpoint.expectedHeaderReceived("last", "three");
// Access to one specific array element
mockEndpoint.expectedHeaderReceived("first.length", "one".length());
mockEndpoint.expectedHeaderReceived("first.uppercase", "ONE");
String[] array = new String[]{"one", "two", "three"};
sendBody("direct:in", array);
assertMockEndpointsSatisfied();
}
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:in")
.setHeader("length", simple("${body.length}"))
.setHeader("first", simple("${body[0]}"))
.setHeader("last", simple("${body[last]}"))
.setHeader("first.length", simple("${body[0].length}"))
.setHeader("first.uppercase",
simple("${body[0].toUpperCase()}"))
.to("mock:end");
}
};
}
}
> -----Ursprüngliche Nachricht-----
> Von: Claus Ibsen [mailto:[email protected]]
> Gesendet: Freitag, 5. Dezember 2014 12:51
> An: [email protected]
> Betreff: Re: AW: Camel - Array
>
> Hi
>
> If you spend 2 days and cannot figure it out, then just write what you
> would do in plain java. And then call the java code from the Camel
> route using the bean component / method call expression or a Camel
> processor.
>
>
> On Fri, Dec 5, 2014 at 11:59 AM, smilevasu6 <[email protected]>
> wrote:
> > Hi,
> >
> > I am not bother about the size.
> >
> > I need to fetch the element name like if it is <xs:element
> > name="Address"> i need to get "name" but not hard coded ex:
> > setHeader("size",simple("${body.getName}")) it should returns me
> > Address. so that i can use the value later.
> >
> > Please do let help me. I am browsing from past 2 days.
> >
> >
> >
> > --
> > View this message in context:
> > http://camel.465427.n5.nabble.com/Camel-Array-tp5760111p5760196.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: [email protected]
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
> hawtio: http://hawt.io/
> fabric8: http://fabric8.io/