You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Jonathan Vila Lopez <jo...@gmail.com> on 2014/10/27 00:25:49 UTC

Simple and easy REST client with Camel

Hello

I have a very simple problem to solve but I've not been capable of sorting
out.

Have one REST remote webservice from Marvel, and would like to create a
route that calls that webservice, gets the JSon response, and finally
prints out 3 of its attributes.

One told me the easiest approach would be to use an HTTP adapter and then a
json component.

This is what I have for now :

                from("
http://gateway.marvel.com:80/v1/public/comics?dateDescriptor=nextWeek&ts=987&apikey=97f295907072a970c5df30d73d1f3816&hash=abfa1c1d42a73a5eab042242335d805d
").
                        unmarshal().json(JsonLibrary.Jackson).
                        setBody(simple("my attributes are :
${body?.code?}")).
                        to("stream:out");

But in the setBody line I dont get anything.....

The structure of the JSON is like this :

{
  "code": "int",
  "status": "string",
  "data": {
    "offset": "int",
    "limit": "int",
    "total": "int",
    "results": [
      {
        "id": "int",
        "digitalId": "int",
        "title": "string",
        "description": "string",
        "prices": [
          {
            "type": "string",
            "price": "float"
          }
        ],
        "thumbnail": {
          "path": "string",
          "extension": "string"
        } ] }
}

And I would like to get the values for "code", "data.results.title",
"data.results.prices.price", "data.results.thumbnail.path"

Any help ?


[image: Inline image 2]

* Jonathan Vila    ** <https://www.twitter.com/jonathan_vila>
<http://www.linkedin.com/in/jonathanvila>*


* jonathan.vila@gmail.com <jo...@gmail.com>*

Re: Simple and easy REST client with Camel

Posted by Charles Moulliard <ch...@gmail.com>.
Stream caching is described here :
http://camel.apache.org/stream-caching.html

On Mon, Oct 27, 2014 at 12:41 PM, Jonathan Vila Lopez <
jonathan.vila@gmail.com> wrote:

> Hi Charles
>
> You are right..... thank you a lot.
>
> Is that explained in any documentation page ? to read the source.....
>
> Kind regards.
>
>
> [image: Inline image 2]
>
> * Jonathan Vila    ** <https://www.twitter.com/jonathan_vila>
> <http://www.linkedin.com/in/jonathanvila>*
>
>
> * jonathan.vila@gmail.com <jo...@gmail.com>*
>
>
>
>
> On Mon, Oct 27, 2014 at 11:52 AM, Charles Moulliard <ch...@gmail.com>
> wrote:
>
>> Your syntax is not correct as umarshalling of a jackson stream (coming
>> from
>> the HTTP request) will return a HashMap. To access to this value using the
>> simple language, this syntax has to be used : simple("${body[code]}")
>>
>> Example :
>>
>>         <route streamCache="true">
>>             <from uri="
>>
>> http://gateway.marvel.com/v1/public/comics?dateDescriptor=nextWeek&amp;ts=987&amp;apikey=97f295907072a970c5df30d73d1f3816&amp;hash=abfa1c1d42a73a5eab042242335d805d
>> "/>
>>             <log message=">> Response received : ${body}"/>
>>             <unmarshal>
>>                 <json library="Jackson"/>
>>             </unmarshal>
>>             <log message="Attribute code : ${body[code]}"/>
>>             <log message="Attribute status : ${body[status]}"/>
>>             <log message="Attribute stacopyrighttus :
>> ${body[copyright]}"/>
>>             <log message="Attribute title  : ${body[title]}"/>
>>         </route>
>>
>> On Mon, Oct 27, 2014 at 11:47 AM, Charles Moulliard <ch...@gmail.com>
>> wrote:
>>
>> > You syntax is not correct as unmarshalling of jackson will return
>> >
>> > On Mon, Oct 27, 2014 at 10:56 AM, Jonathan Vila Lopez <
>> > jonathan.vila@gmail.com> wrote:
>> >
>> >> Hi Charles
>> >>
>> >> Oki, thank you.
>> >>
>> >> But, how can I retrieve 3 attributes from the JSON and print out them ?
>> >> In the line 3 I get nothing in the console, so it seems line 2 in
>> wrong in
>> >> some way....
>> >>
>> >> 1. ​
>> >> unmarshal().json(JsonLibrary.Jackson).
>> >> 2.      setBody(simple("my attributes are : ${body?.code?}")).
>> >> 3.       to("stream:out");
>> >>
>> >> Kind regards.
>> >>
>> >>
>> >> [image: Inline image 2]
>> >>
>> >> * Jonathan Vila    ** <https://www.twitter.com/jonathan_vila>
>> >> <http://www.linkedin.com/in/jonathanvila>*
>> >>
>> >>
>> >> * jonathan.vila@gmail.com <jo...@gmail.com>*
>> >>
>> >>
>> >>
>> >>
>> >> On Mon, Oct 27, 2014 at 10:48 AM, Charles Moulliard <ch...@gmail.com>
>> >> wrote:
>> >>
>> >>> Hi Jonathan,
>> >>>
>> >>> Our documentation is not longer up to date as now the http component
>> >>> proposes / provides also a HttpConsumer (= Polling Consumer) which is
>> >>> able
>> >>> every x second to do a HTTP request. So, you can also use this syntax
>> >>> within your Apache Camel route (from("http://").to("") to poll a HTTP
>> >>> Server.
>> >>>
>> >>> Regards,
>> >>>
>> >>> On Mon, Oct 27, 2014 at 9:48 AM, Jonathan Vila Lopez <
>> >>> jonathan.vila@gmail.com> wrote:
>> >>>
>> >>> > Hello Charles
>> >>> >
>> >>> > But, with that code I used I successfully get the response and
>> >>> > successfully unmarshals it...... in fact, in my code my problem was
>> in
>> >>> the
>> >>> > line of setBody.... I can not get the attributes.
>> >>> >
>> >>> > Anyway I will try your proposal.
>> >>> >
>> >>> > Kind regards.
>> >>> >
>> >>> >
>> >>> > [image: Inline image 2]
>> >>> >
>> >>> > * Jonathan Vila    ** <https://www.twitter.com/jonathan_vila>
>> >>> > <http://www.linkedin.com/in/jonathanvila>*
>> >>> >
>> >>> >
>> >>> > * jonathan.vila@gmail.com <jo...@gmail.com>*
>> >>> >
>> >>> >
>> >>> >
>> >>> >
>> >>> > On Mon, Oct 27, 2014 at 8:57 AM, Charles Moulliard <
>> ch007m@gmail.com>
>> >>> > wrote:
>> >>> >
>> >>> >> Hi Jonathan,
>> >>> >>
>> >>> >> To call the HTTP Server exposing the REST service the HTTP producer
>> >>> must
>> >>> >> be
>> >>> >> used and not the HTTP Consumer component of Camel (
>> >>> >> http://camel.apache.org/http.html). This syntax is not correct
>> >>> >> (from("http://") while this one is correct
>> >>> >>
>> >>> >> from("direct:marvel").to("
>> >>> >>
>> >>> >>
>> >>>
>> http://gateway.marvel.com:80/v1/public/comics?dateDescriptor=nextWeek&ts=987&apikey=97f295907072a970c5df30d73d1f3816&hash=abfa1c1d42a73a5eab042242335d805d
>> >>> >> ").
>> >>> >>
>> >>> ​​
>> >>> unmarshal().json(JsonLibrary.Jackson).
>> >>> >>       setBody(simple("my attributes are : ${body?.code?}")).
>> >>> >>       to("stream:out");
>> >>> >>
>> >>> >> Regards,
>> >>> >>
>> >>> >
>> >>> >
>> >>>
>> >>>
>> >>> --
>> >>> Charles Moulliard
>> >>> Apache Committer / Architect @RedHat
>> >>> Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io
>> >>>
>> >>
>> >>
>> >
>> >
>> > --
>> > Charles Moulliard
>> > Apache Committer / Architect @RedHat
>> > Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io
>> >
>> >
>>
>>
>> --
>> Charles Moulliard
>> Apache Committer / Architect @RedHat
>> Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io
>>
>
>


-- 
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io

Re: Simple and easy REST client with Camel

Posted by Jonathan Vila Lopez <jo...@gmail.com>.
Hi Charles

You are right..... thank you a lot.

Is that explained in any documentation page ? to read the source.....

Kind regards.


[image: Inline image 2]

* Jonathan Vila    ** <https://www.twitter.com/jonathan_vila>
<http://www.linkedin.com/in/jonathanvila>*


* jonathan.vila@gmail.com <jo...@gmail.com>*




On Mon, Oct 27, 2014 at 11:52 AM, Charles Moulliard <ch...@gmail.com>
wrote:

> Your syntax is not correct as umarshalling of a jackson stream (coming from
> the HTTP request) will return a HashMap. To access to this value using the
> simple language, this syntax has to be used : simple("${body[code]}")
>
> Example :
>
>         <route streamCache="true">
>             <from uri="
>
> http://gateway.marvel.com/v1/public/comics?dateDescriptor=nextWeek&amp;ts=987&amp;apikey=97f295907072a970c5df30d73d1f3816&amp;hash=abfa1c1d42a73a5eab042242335d805d
> "/>
>             <log message=">> Response received : ${body}"/>
>             <unmarshal>
>                 <json library="Jackson"/>
>             </unmarshal>
>             <log message="Attribute code : ${body[code]}"/>
>             <log message="Attribute status : ${body[status]}"/>
>             <log message="Attribute stacopyrighttus : ${body[copyright]}"/>
>             <log message="Attribute title  : ${body[title]}"/>
>         </route>
>
> On Mon, Oct 27, 2014 at 11:47 AM, Charles Moulliard <ch...@gmail.com>
> wrote:
>
> > You syntax is not correct as unmarshalling of jackson will return
> >
> > On Mon, Oct 27, 2014 at 10:56 AM, Jonathan Vila Lopez <
> > jonathan.vila@gmail.com> wrote:
> >
> >> Hi Charles
> >>
> >> Oki, thank you.
> >>
> >> But, how can I retrieve 3 attributes from the JSON and print out them ?
> >> In the line 3 I get nothing in the console, so it seems line 2 in wrong
> in
> >> some way....
> >>
> >> 1. ​
> >> unmarshal().json(JsonLibrary.Jackson).
> >> 2.      setBody(simple("my attributes are : ${body?.code?}")).
> >> 3.       to("stream:out");
> >>
> >> Kind regards.
> >>
> >>
> >> [image: Inline image 2]
> >>
> >> * Jonathan Vila    ** <https://www.twitter.com/jonathan_vila>
> >> <http://www.linkedin.com/in/jonathanvila>*
> >>
> >>
> >> * jonathan.vila@gmail.com <jo...@gmail.com>*
> >>
> >>
> >>
> >>
> >> On Mon, Oct 27, 2014 at 10:48 AM, Charles Moulliard <ch...@gmail.com>
> >> wrote:
> >>
> >>> Hi Jonathan,
> >>>
> >>> Our documentation is not longer up to date as now the http component
> >>> proposes / provides also a HttpConsumer (= Polling Consumer) which is
> >>> able
> >>> every x second to do a HTTP request. So, you can also use this syntax
> >>> within your Apache Camel route (from("http://").to("") to poll a HTTP
> >>> Server.
> >>>
> >>> Regards,
> >>>
> >>> On Mon, Oct 27, 2014 at 9:48 AM, Jonathan Vila Lopez <
> >>> jonathan.vila@gmail.com> wrote:
> >>>
> >>> > Hello Charles
> >>> >
> >>> > But, with that code I used I successfully get the response and
> >>> > successfully unmarshals it...... in fact, in my code my problem was
> in
> >>> the
> >>> > line of setBody.... I can not get the attributes.
> >>> >
> >>> > Anyway I will try your proposal.
> >>> >
> >>> > Kind regards.
> >>> >
> >>> >
> >>> > [image: Inline image 2]
> >>> >
> >>> > * Jonathan Vila    ** <https://www.twitter.com/jonathan_vila>
> >>> > <http://www.linkedin.com/in/jonathanvila>*
> >>> >
> >>> >
> >>> > * jonathan.vila@gmail.com <jo...@gmail.com>*
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > On Mon, Oct 27, 2014 at 8:57 AM, Charles Moulliard <ch007m@gmail.com
> >
> >>> > wrote:
> >>> >
> >>> >> Hi Jonathan,
> >>> >>
> >>> >> To call the HTTP Server exposing the REST service the HTTP producer
> >>> must
> >>> >> be
> >>> >> used and not the HTTP Consumer component of Camel (
> >>> >> http://camel.apache.org/http.html). This syntax is not correct
> >>> >> (from("http://") while this one is correct
> >>> >>
> >>> >> from("direct:marvel").to("
> >>> >>
> >>> >>
> >>>
> http://gateway.marvel.com:80/v1/public/comics?dateDescriptor=nextWeek&ts=987&apikey=97f295907072a970c5df30d73d1f3816&hash=abfa1c1d42a73a5eab042242335d805d
> >>> >> ").
> >>> >>
> >>> ​​
> >>> unmarshal().json(JsonLibrary.Jackson).
> >>> >>       setBody(simple("my attributes are : ${body?.code?}")).
> >>> >>       to("stream:out");
> >>> >>
> >>> >> Regards,
> >>> >>
> >>> >
> >>> >
> >>>
> >>>
> >>> --
> >>> Charles Moulliard
> >>> Apache Committer / Architect @RedHat
> >>> Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io
> >>>
> >>
> >>
> >
> >
> > --
> > Charles Moulliard
> > Apache Committer / Architect @RedHat
> > Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io
> >
> >
>
>
> --
> Charles Moulliard
> Apache Committer / Architect @RedHat
> Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io
>

Re: Simple and easy REST client with Camel

Posted by Charles Moulliard <ch...@gmail.com>.
Your syntax is not correct as umarshalling of a jackson stream (coming from
the HTTP request) will return a HashMap. To access to this value using the
simple language, this syntax has to be used : simple("${body[code]}")

Example :

        <route streamCache="true">
            <from uri="
http://gateway.marvel.com/v1/public/comics?dateDescriptor=nextWeek&amp;ts=987&amp;apikey=97f295907072a970c5df30d73d1f3816&amp;hash=abfa1c1d42a73a5eab042242335d805d
"/>
            <log message=">> Response received : ${body}"/>
            <unmarshal>
                <json library="Jackson"/>
            </unmarshal>
            <log message="Attribute code : ${body[code]}"/>
            <log message="Attribute status : ${body[status]}"/>
            <log message="Attribute stacopyrighttus : ${body[copyright]}"/>
            <log message="Attribute title  : ${body[title]}"/>
        </route>

On Mon, Oct 27, 2014 at 11:47 AM, Charles Moulliard <ch...@gmail.com>
wrote:

> You syntax is not correct as unmarshalling of jackson will return
>
> On Mon, Oct 27, 2014 at 10:56 AM, Jonathan Vila Lopez <
> jonathan.vila@gmail.com> wrote:
>
>> Hi Charles
>>
>> Oki, thank you.
>>
>> But, how can I retrieve 3 attributes from the JSON and print out them ?
>> In the line 3 I get nothing in the console, so it seems line 2 in wrong in
>> some way....
>>
>> 1. ​
>> unmarshal().json(JsonLibrary.Jackson).
>> 2.      setBody(simple("my attributes are : ${body?.code?}")).
>> 3.       to("stream:out");
>>
>> Kind regards.
>>
>>
>> [image: Inline image 2]
>>
>> * Jonathan Vila    ** <https://www.twitter.com/jonathan_vila>
>> <http://www.linkedin.com/in/jonathanvila>*
>>
>>
>> * jonathan.vila@gmail.com <jo...@gmail.com>*
>>
>>
>>
>>
>> On Mon, Oct 27, 2014 at 10:48 AM, Charles Moulliard <ch...@gmail.com>
>> wrote:
>>
>>> Hi Jonathan,
>>>
>>> Our documentation is not longer up to date as now the http component
>>> proposes / provides also a HttpConsumer (= Polling Consumer) which is
>>> able
>>> every x second to do a HTTP request. So, you can also use this syntax
>>> within your Apache Camel route (from("http://").to("") to poll a HTTP
>>> Server.
>>>
>>> Regards,
>>>
>>> On Mon, Oct 27, 2014 at 9:48 AM, Jonathan Vila Lopez <
>>> jonathan.vila@gmail.com> wrote:
>>>
>>> > Hello Charles
>>> >
>>> > But, with that code I used I successfully get the response and
>>> > successfully unmarshals it...... in fact, in my code my problem was in
>>> the
>>> > line of setBody.... I can not get the attributes.
>>> >
>>> > Anyway I will try your proposal.
>>> >
>>> > Kind regards.
>>> >
>>> >
>>> > [image: Inline image 2]
>>> >
>>> > * Jonathan Vila    ** <https://www.twitter.com/jonathan_vila>
>>> > <http://www.linkedin.com/in/jonathanvila>*
>>> >
>>> >
>>> > * jonathan.vila@gmail.com <jo...@gmail.com>*
>>> >
>>> >
>>> >
>>> >
>>> > On Mon, Oct 27, 2014 at 8:57 AM, Charles Moulliard <ch...@gmail.com>
>>> > wrote:
>>> >
>>> >> Hi Jonathan,
>>> >>
>>> >> To call the HTTP Server exposing the REST service the HTTP producer
>>> must
>>> >> be
>>> >> used and not the HTTP Consumer component of Camel (
>>> >> http://camel.apache.org/http.html). This syntax is not correct
>>> >> (from("http://") while this one is correct
>>> >>
>>> >> from("direct:marvel").to("
>>> >>
>>> >>
>>> http://gateway.marvel.com:80/v1/public/comics?dateDescriptor=nextWeek&ts=987&apikey=97f295907072a970c5df30d73d1f3816&hash=abfa1c1d42a73a5eab042242335d805d
>>> >> ").
>>> >>
>>> ​​
>>> unmarshal().json(JsonLibrary.Jackson).
>>> >>       setBody(simple("my attributes are : ${body?.code?}")).
>>> >>       to("stream:out");
>>> >>
>>> >> Regards,
>>> >>
>>> >
>>> >
>>>
>>>
>>> --
>>> Charles Moulliard
>>> Apache Committer / Architect @RedHat
>>> Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io
>>>
>>
>>
>
>
> --
> Charles Moulliard
> Apache Committer / Architect @RedHat
> Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io
>
>


-- 
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io

Re: Simple and easy REST client with Camel

Posted by Charles Moulliard <ch...@gmail.com>.
You syntax is not correct as unmarshalling of jackson will return

On Mon, Oct 27, 2014 at 10:56 AM, Jonathan Vila Lopez <
jonathan.vila@gmail.com> wrote:

> Hi Charles
>
> Oki, thank you.
>
> But, how can I retrieve 3 attributes from the JSON and print out them ? In
> the line 3 I get nothing in the console, so it seems line 2 in wrong in
> some way....
>
> 1. ​
> unmarshal().json(JsonLibrary.Jackson).
> 2.      setBody(simple("my attributes are : ${body?.code?}")).
> 3.       to("stream:out");
>
> Kind regards.
>
>
> [image: Inline image 2]
>
> * Jonathan Vila    ** <https://www.twitter.com/jonathan_vila>
> <http://www.linkedin.com/in/jonathanvila>*
>
>
> * jonathan.vila@gmail.com <jo...@gmail.com>*
>
>
>
>
> On Mon, Oct 27, 2014 at 10:48 AM, Charles Moulliard <ch...@gmail.com>
> wrote:
>
>> Hi Jonathan,
>>
>> Our documentation is not longer up to date as now the http component
>> proposes / provides also a HttpConsumer (= Polling Consumer) which is able
>> every x second to do a HTTP request. So, you can also use this syntax
>> within your Apache Camel route (from("http://").to("") to poll a HTTP
>> Server.
>>
>> Regards,
>>
>> On Mon, Oct 27, 2014 at 9:48 AM, Jonathan Vila Lopez <
>> jonathan.vila@gmail.com> wrote:
>>
>> > Hello Charles
>> >
>> > But, with that code I used I successfully get the response and
>> > successfully unmarshals it...... in fact, in my code my problem was in
>> the
>> > line of setBody.... I can not get the attributes.
>> >
>> > Anyway I will try your proposal.
>> >
>> > Kind regards.
>> >
>> >
>> > [image: Inline image 2]
>> >
>> > * Jonathan Vila    ** <https://www.twitter.com/jonathan_vila>
>> > <http://www.linkedin.com/in/jonathanvila>*
>> >
>> >
>> > * jonathan.vila@gmail.com <jo...@gmail.com>*
>> >
>> >
>> >
>> >
>> > On Mon, Oct 27, 2014 at 8:57 AM, Charles Moulliard <ch...@gmail.com>
>> > wrote:
>> >
>> >> Hi Jonathan,
>> >>
>> >> To call the HTTP Server exposing the REST service the HTTP producer
>> must
>> >> be
>> >> used and not the HTTP Consumer component of Camel (
>> >> http://camel.apache.org/http.html). This syntax is not correct
>> >> (from("http://") while this one is correct
>> >>
>> >> from("direct:marvel").to("
>> >>
>> >>
>> http://gateway.marvel.com:80/v1/public/comics?dateDescriptor=nextWeek&ts=987&apikey=97f295907072a970c5df30d73d1f3816&hash=abfa1c1d42a73a5eab042242335d805d
>> >> ").
>> >>
>> ​​
>> unmarshal().json(JsonLibrary.Jackson).
>> >>       setBody(simple("my attributes are : ${body?.code?}")).
>> >>       to("stream:out");
>> >>
>> >> Regards,
>> >>
>> >
>> >
>>
>>
>> --
>> Charles Moulliard
>> Apache Committer / Architect @RedHat
>> Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io
>>
>
>


-- 
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io

Re: Simple and easy REST client with Camel

Posted by Jonathan Vila Lopez <jo...@gmail.com>.
Hi Charles

Oki, thank you.

But, how can I retrieve 3 attributes from the JSON and print out them ? In
the line 3 I get nothing in the console, so it seems line 2 in wrong in
some way....

1. ​
unmarshal().json(JsonLibrary.Jackson).
2.      setBody(simple("my attributes are : ${body?.code?}")).
3.       to("stream:out");

Kind regards.


[image: Inline image 2]

* Jonathan Vila    ** <https://www.twitter.com/jonathan_vila>
<http://www.linkedin.com/in/jonathanvila>*


* jonathan.vila@gmail.com <jo...@gmail.com>*




On Mon, Oct 27, 2014 at 10:48 AM, Charles Moulliard <ch...@gmail.com>
wrote:

> Hi Jonathan,
>
> Our documentation is not longer up to date as now the http component
> proposes / provides also a HttpConsumer (= Polling Consumer) which is able
> every x second to do a HTTP request. So, you can also use this syntax
> within your Apache Camel route (from("http://").to("") to poll a HTTP
> Server.
>
> Regards,
>
> On Mon, Oct 27, 2014 at 9:48 AM, Jonathan Vila Lopez <
> jonathan.vila@gmail.com> wrote:
>
> > Hello Charles
> >
> > But, with that code I used I successfully get the response and
> > successfully unmarshals it...... in fact, in my code my problem was in
> the
> > line of setBody.... I can not get the attributes.
> >
> > Anyway I will try your proposal.
> >
> > Kind regards.
> >
> >
> > [image: Inline image 2]
> >
> > * Jonathan Vila    ** <https://www.twitter.com/jonathan_vila>
> > <http://www.linkedin.com/in/jonathanvila>*
> >
> >
> > * jonathan.vila@gmail.com <jo...@gmail.com>*
> >
> >
> >
> >
> > On Mon, Oct 27, 2014 at 8:57 AM, Charles Moulliard <ch...@gmail.com>
> > wrote:
> >
> >> Hi Jonathan,
> >>
> >> To call the HTTP Server exposing the REST service the HTTP producer must
> >> be
> >> used and not the HTTP Consumer component of Camel (
> >> http://camel.apache.org/http.html). This syntax is not correct
> >> (from("http://") while this one is correct
> >>
> >> from("direct:marvel").to("
> >>
> >>
> http://gateway.marvel.com:80/v1/public/comics?dateDescriptor=nextWeek&ts=987&apikey=97f295907072a970c5df30d73d1f3816&hash=abfa1c1d42a73a5eab042242335d805d
> >> ").
> >>
> ​​
> unmarshal().json(JsonLibrary.Jackson).
> >>       setBody(simple("my attributes are : ${body?.code?}")).
> >>       to("stream:out");
> >>
> >> Regards,
> >>
> >
> >
>
>
> --
> Charles Moulliard
> Apache Committer / Architect @RedHat
> Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io
>

Re: Simple and easy REST client with Camel

Posted by Charles Moulliard <ch...@gmail.com>.
Hi Jonathan,

Our documentation is not longer up to date as now the http component
proposes / provides also a HttpConsumer (= Polling Consumer) which is able
every x second to do a HTTP request. So, you can also use this syntax
within your Apache Camel route (from("http://").to("") to poll a HTTP
Server.

Regards,

On Mon, Oct 27, 2014 at 9:48 AM, Jonathan Vila Lopez <
jonathan.vila@gmail.com> wrote:

> Hello Charles
>
> But, with that code I used I successfully get the response and
> successfully unmarshals it...... in fact, in my code my problem was in the
> line of setBody.... I can not get the attributes.
>
> Anyway I will try your proposal.
>
> Kind regards.
>
>
> [image: Inline image 2]
>
> * Jonathan Vila    ** <https://www.twitter.com/jonathan_vila>
> <http://www.linkedin.com/in/jonathanvila>*
>
>
> * jonathan.vila@gmail.com <jo...@gmail.com>*
>
>
>
>
> On Mon, Oct 27, 2014 at 8:57 AM, Charles Moulliard <ch...@gmail.com>
> wrote:
>
>> Hi Jonathan,
>>
>> To call the HTTP Server exposing the REST service the HTTP producer must
>> be
>> used and not the HTTP Consumer component of Camel (
>> http://camel.apache.org/http.html). This syntax is not correct
>> (from("http://") while this one is correct
>>
>> from("direct:marvel").to("
>>
>> http://gateway.marvel.com:80/v1/public/comics?dateDescriptor=nextWeek&ts=987&apikey=97f295907072a970c5df30d73d1f3816&hash=abfa1c1d42a73a5eab042242335d805d
>> ").
>>       unmarshal().json(JsonLibrary.Jackson).
>>       setBody(simple("my attributes are : ${body?.code?}")).
>>       to("stream:out");
>>
>> Regards,
>>
>
>


-- 
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io

Re: Simple and easy REST client with Camel

Posted by Jonathan Vila Lopez <jo...@gmail.com>.
Hello Charles

But, with that code I used I successfully get the response and successfully
unmarshals it...... in fact, in my code my problem was in the line of
setBody.... I can not get the attributes.

Anyway I will try your proposal.

Kind regards.


[image: Inline image 2]

* Jonathan Vila    ** <https://www.twitter.com/jonathan_vila>
<http://www.linkedin.com/in/jonathanvila>*


* jonathan.vila@gmail.com <jo...@gmail.com>*




On Mon, Oct 27, 2014 at 8:57 AM, Charles Moulliard <ch...@gmail.com> wrote:

> Hi Jonathan,
>
> To call the HTTP Server exposing the REST service the HTTP producer must be
> used and not the HTTP Consumer component of Camel (
> http://camel.apache.org/http.html). This syntax is not correct
> (from("http://") while this one is correct
>
> from("direct:marvel").to("
>
> http://gateway.marvel.com:80/v1/public/comics?dateDescriptor=nextWeek&ts=987&apikey=97f295907072a970c5df30d73d1f3816&hash=abfa1c1d42a73a5eab042242335d805d
> ").
>       unmarshal().json(JsonLibrary.Jackson).
>       setBody(simple("my attributes are : ${body?.code?}")).
>       to("stream:out");
>
> Regards,
>

Re: Simple and easy REST client with Camel

Posted by Charles Moulliard <ch...@gmail.com>.
Hi Jonathan,

To call the HTTP Server exposing the REST service the HTTP producer must be
used and not the HTTP Consumer component of Camel (
http://camel.apache.org/http.html). This syntax is not correct
(from("http://") while this one is correct

from("direct:marvel").to("
http://gateway.marvel.com:80/v1/public/comics?dateDescriptor=nextWeek&ts=987&apikey=97f295907072a970c5df30d73d1f3816&hash=abfa1c1d42a73a5eab042242335d805d
").
      unmarshal().json(JsonLibrary.Jackson).
      setBody(simple("my attributes are : ${body?.code?}")).
      to("stream:out");

Regards,