You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Nasim Anza <na...@googlemail.com> on 2009/05/20 14:39:43 UTC
Get a list of values from processor
Hi,
I would like to get a list of values from an XML input using the Camel
route.
Assume that we have an XML input like below :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns="http://myNamesapce">
<soapenv:Header/>
<soapenv:Body>
<ns:Addresses>
<Address>address1</Address>
<Address>address2</Address>
<Address>address3</Address>
<Address>address4</Address>
</ns:Addresses>
</soapenv:Body>
</soapenv:Envelope>
How to get the list of address values from a Camel Processor within a route
:
from("direct:start")
.setProperty("Addresses").xpath("//Address", ArrayList.class)
.process(myCamelProcessor);
Thanks for help
Nasmo
Re: Get a list of values from processor
Posted by Nasim Anza <na...@googlemail.com>.
Thanks, it works also for me.
Nasmo
On Wed, May 27, 2009 at 2:41 AM, Willem Jiang <wi...@gmail.com>wrote:
> Hi,
>
> I just wrote a simple unit test which was based on your case in Camel
> 2.0 trunk.
> The code works for me, please feel free to check it[1] out.
>
> [1]
>
> http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/language/XPathFunctionTest.java?view=diff&r1=778973&r2=778974&pathrev=778974
>
> Willem
>
> Nasim Anza wrote:
> > Hi,
> > I've tried with NodeList in the Camel configure() method :
> > from("direct:start").setProperty("Addresses").xpath("//Address",
> > NodeList.class)
> > .process(myCamelProcessor);
> >
> > In the Process(Exchange ex) method I got a ClassCastException when I
> tried
> > to get values :
> > NodeList adresses = (NodeList)ex.getProperty("Addresses");
> >
> > Any idea will be apprecioated.
> > Thanks
> >
> > Nasmo
> >
> >
> > and in the procesor
> >
> > On Sat, May 23, 2009 at 7:42 AM, Claus Ibsen <cl...@gmail.com>
> wrote:
> >
> >> On Wed, May 20, 2009 at 2:39 PM, Nasim Anza <na...@googlemail.com>
> >> wrote:
> >>> Hi,
> >>>
> >>> I would like to get a list of values from an XML input using the Camel
> >>> route.
> >>> Assume that we have an XML input like below :
> >>>
> >>> <soapenv:Envelope xmlns:soapenv="
> >> http://schemas.xmlsoap.org/soap/envelope/"
> >>> xmlns:ns="http://myNamesapce <http://mynamesapce/>">
> >>> <soapenv:Header/>
> >>> <soapenv:Body>
> >>> <ns:Addresses>
> >>> <Address>address1</Address>
> >>> <Address>address2</Address>
> >>> <Address>address3</Address>
> >>> <Address>address4</Address>
> >>> </ns:Addresses>
> >>> </soapenv:Body>
> >>> </soapenv:Envelope>
> >>>
> >>> How to get the list of address values from a Camel Processor within a
> >> route
> >>> :
> >>>
> >>> from("direct:start")
> >>> .setProperty("Addresses").xpath("//Address", ArrayList.class)
> >>> .process(myCamelProcessor);
> >> Hi
> >>
> >> Have you tried without the ArrayList.class as the xpath is kind hard
> >> to get working. As it tends to want to use XML types such as NodeList
> >> etc.
> >>
> >>
> >>
> >>> Thanks for help
> >>>
> >>> Nasmo
> >>>
> >>
> >>
> >> --
> >> Claus Ibsen
> >> Apache Camel Committer
> >>
> >> Open Source Integration: http://fusesource.com
> >> Blog: http://davsclaus.blogspot.com/
> >> Twitter: http://twitter.com/davsclaus
> >>
> >
>
>
Re: Get a list of values from processor
Posted by Willem Jiang <wi...@gmail.com>.
Hi,
I just wrote a simple unit test which was based on your case in Camel
2.0 trunk.
The code works for me, please feel free to check it[1] out.
[1]
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/language/XPathFunctionTest.java?view=diff&r1=778973&r2=778974&pathrev=778974
Willem
Nasim Anza wrote:
> Hi,
> I've tried with NodeList in the Camel configure() method :
> from("direct:start").setProperty("Addresses").xpath("//Address",
> NodeList.class)
> .process(myCamelProcessor);
>
> In the Process(Exchange ex) method I got a ClassCastException when I tried
> to get values :
> NodeList adresses = (NodeList)ex.getProperty("Addresses");
>
> Any idea will be apprecioated.
> Thanks
>
> Nasmo
>
>
> and in the procesor
>
> On Sat, May 23, 2009 at 7:42 AM, Claus Ibsen <cl...@gmail.com> wrote:
>
>> On Wed, May 20, 2009 at 2:39 PM, Nasim Anza <na...@googlemail.com>
>> wrote:
>>> Hi,
>>>
>>> I would like to get a list of values from an XML input using the Camel
>>> route.
>>> Assume that we have an XML input like below :
>>>
>>> <soapenv:Envelope xmlns:soapenv="
>> http://schemas.xmlsoap.org/soap/envelope/"
>>> xmlns:ns="http://myNamesapce">
>>> <soapenv:Header/>
>>> <soapenv:Body>
>>> <ns:Addresses>
>>> <Address>address1</Address>
>>> <Address>address2</Address>
>>> <Address>address3</Address>
>>> <Address>address4</Address>
>>> </ns:Addresses>
>>> </soapenv:Body>
>>> </soapenv:Envelope>
>>>
>>> How to get the list of address values from a Camel Processor within a
>> route
>>> :
>>>
>>> from("direct:start")
>>> .setProperty("Addresses").xpath("//Address", ArrayList.class)
>>> .process(myCamelProcessor);
>> Hi
>>
>> Have you tried without the ArrayList.class as the xpath is kind hard
>> to get working. As it tends to want to use XML types such as NodeList
>> etc.
>>
>>
>>
>>> Thanks for help
>>>
>>> Nasmo
>>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>
Re: Get a list of values from processor
Posted by Nasim Anza <na...@googlemail.com>.
Hi,
I've tried with NodeList in the Camel configure() method :
from("direct:start").setProperty("Addresses").xpath("//Address",
NodeList.class)
.process(myCamelProcessor);
In the Process(Exchange ex) method I got a ClassCastException when I tried
to get values :
NodeList adresses = (NodeList)ex.getProperty("Addresses");
Any idea will be apprecioated.
Thanks
Nasmo
and in the procesor
On Sat, May 23, 2009 at 7:42 AM, Claus Ibsen <cl...@gmail.com> wrote:
> On Wed, May 20, 2009 at 2:39 PM, Nasim Anza <na...@googlemail.com>
> wrote:
> > Hi,
> >
> > I would like to get a list of values from an XML input using the Camel
> > route.
> > Assume that we have an XML input like below :
> >
> > <soapenv:Envelope xmlns:soapenv="
> http://schemas.xmlsoap.org/soap/envelope/"
> > xmlns:ns="http://myNamesapce">
> > <soapenv:Header/>
> > <soapenv:Body>
> > <ns:Addresses>
> > <Address>address1</Address>
> > <Address>address2</Address>
> > <Address>address3</Address>
> > <Address>address4</Address>
> > </ns:Addresses>
> > </soapenv:Body>
> > </soapenv:Envelope>
> >
> > How to get the list of address values from a Camel Processor within a
> route
> > :
> >
> > from("direct:start")
> > .setProperty("Addresses").xpath("//Address", ArrayList.class)
> > .process(myCamelProcessor);
> Hi
>
> Have you tried without the ArrayList.class as the xpath is kind hard
> to get working. As it tends to want to use XML types such as NodeList
> etc.
>
>
>
> >
> > Thanks for help
> >
> > Nasmo
> >
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>
Re: Get a list of values from processor
Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, May 20, 2009 at 2:39 PM, Nasim Anza <na...@googlemail.com> wrote:
> Hi,
>
> I would like to get a list of values from an XML input using the Camel
> route.
> Assume that we have an XML input like below :
>
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:ns="http://myNamesapce">
> <soapenv:Header/>
> <soapenv:Body>
> <ns:Addresses>
> <Address>address1</Address>
> <Address>address2</Address>
> <Address>address3</Address>
> <Address>address4</Address>
> </ns:Addresses>
> </soapenv:Body>
> </soapenv:Envelope>
>
> How to get the list of address values from a Camel Processor within a route
> :
>
> from("direct:start")
> .setProperty("Addresses").xpath("//Address", ArrayList.class)
> .process(myCamelProcessor);
Hi
Have you tried without the ArrayList.class as the xpath is kind hard
to get working. As it tends to want to use XML types such as NodeList
etc.
>
> Thanks for help
>
> Nasmo
>
--
Claus Ibsen
Apache Camel Committer
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus