You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Yee Keat Phuah <yk...@gmail.com> on 2017/07/21 02:33:38 UTC

Possible to use Camel as a translator/proxy for web service?

I have a client that will be calling a webservice, based on certain
signature, e.g. /ticketDescriptionGet?ID123, and expect to get back the
description of the tickets. I want to use Camel to hook it up to a server
serving a Web Service that uses a different URL and also a different Reply
format.

With the following set up, I can get back the whole reply from the server:
    from("netty4-http:http://localhost:8080/ticketDescriptionGet")
                        .choice()
                        .when(header(HEADER).startsWith(PREFIX_INCIDENT))
                        .to(("http4:" + URL_INCIDENT + header(HEADER)
                                + "&bridgeEndpoint=true&view=expand"));

The server's reply is in a json format, that I want to extract just a piece
of information from it.

So I tried something like this:
              from("netty4-http:http://localhost:8080/ticketDescriptionGet")
                        .choice()
                        .when(header(HEADER).startsWith(PREFIX_INCIDENT))
                        .to(("http4:" + URL_INCIDENT + header(HEADER)
                                + "&bridgeEndpoint=true&view=expand"))
                        .transform().jsonpath(JSONPATH_INCIDENT);

But it doesn't work. I understand that if I put the transform before the
"to", then the transform will work on the Request message instead of the
Reply.

I have read the Request-Reply pattern in the camel website but still
couldn't figure out how to do this. Is this possible at all?

Thanks in advance!
-- 
Cheers,
Phuah Yee Keat

Re: Possible to use Camel as a translator/proxy for web service?

Posted by Yee Keat Phuah <yk...@gmail.com>.
Thanks!

It worked fine! Not sure what was wrong previously.

On Sat, Jul 22, 2017 at 3:15 AM, Tomohisa Igarashi <tm...@gmail.com>
wrote:

> Hi,
>
> It just works fine for me
> https://github.com/igarashitm/issues/blob/master/camel/misc/
> src/test/java/JsonPathTransformTest.java
>
> Thanks,
> Tomo
>
>
> On 07/20/2017 10:33 PM, Yee Keat Phuah wrote:
>
>> I have a client that will be calling a webservice, based on certain
>> signature, e.g. /ticketDescriptionGet?ID123, and expect to get back the
>> description of the tickets. I want to use Camel to hook it up to a server
>> serving a Web Service that uses a different URL and also a different Reply
>> format.
>>
>> With the following set up, I can get back the whole reply from the server:
>>      from("netty4-http:http://localhost:8080/ticketDescriptionGet")
>>                          .choice()
>>                          .when(header(HEADER).startsWi
>> th(PREFIX_INCIDENT))
>>                          .to(("http4:" + URL_INCIDENT + header(HEADER)
>>                                  + "&bridgeEndpoint=true&view=expand"));
>>
>> The server's reply is in a json format, that I want to extract just a
>> piece
>> of information from it.
>>
>> So I tried something like this:
>>                from("netty4-http:http://loca
>> lhost:8080/ticketDescriptionGet")
>>                          .choice()
>>                          .when(header(HEADER).startsWi
>> th(PREFIX_INCIDENT))
>>                          .to(("http4:" + URL_INCIDENT + header(HEADER)
>>                                  + "&bridgeEndpoint=true&view=expand"))
>>                          .transform().jsonpath(JSONPATH_INCIDENT);
>>
>> But it doesn't work. I understand that if I put the transform before the
>> "to", then the transform will work on the Request message instead of the
>> Reply.
>>
>> I have read the Request-Reply pattern in the camel website but still
>> couldn't figure out how to do this. Is this possible at all?
>>
>> Thanks in advance!
>>
>>


-- 
Cheers,
Phuah Yee Keat

Re: Possible to use Camel as a translator/proxy for web service?

Posted by Tomohisa Igarashi <tm...@gmail.com>.
Hi,

It just works fine for me
https://github.com/igarashitm/issues/blob/master/camel/misc/src/test/java/JsonPathTransformTest.java

Thanks,
Tomo

On 07/20/2017 10:33 PM, Yee Keat Phuah wrote:
> I have a client that will be calling a webservice, based on certain
> signature, e.g. /ticketDescriptionGet?ID123, and expect to get back the
> description of the tickets. I want to use Camel to hook it up to a server
> serving a Web Service that uses a different URL and also a different Reply
> format.
> 
> With the following set up, I can get back the whole reply from the server:
>      from("netty4-http:http://localhost:8080/ticketDescriptionGet")
>                          .choice()
>                          .when(header(HEADER).startsWith(PREFIX_INCIDENT))
>                          .to(("http4:" + URL_INCIDENT + header(HEADER)
>                                  + "&bridgeEndpoint=true&view=expand"));
> 
> The server's reply is in a json format, that I want to extract just a piece
> of information from it.
> 
> So I tried something like this:
>                from("netty4-http:http://localhost:8080/ticketDescriptionGet")
>                          .choice()
>                          .when(header(HEADER).startsWith(PREFIX_INCIDENT))
>                          .to(("http4:" + URL_INCIDENT + header(HEADER)
>                                  + "&bridgeEndpoint=true&view=expand"))
>                          .transform().jsonpath(JSONPATH_INCIDENT);
> 
> But it doesn't work. I understand that if I put the transform before the
> "to", then the transform will work on the Request message instead of the
> Reply.
> 
> I have read the Request-Reply pattern in the camel website but still
> couldn't figure out how to do this. Is this possible at all?
> 
> Thanks in advance!
>