[ 
https://issues.apache.org/jira/browse/CAMEL-12541?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Willian Antunes updated CAMEL-12541:
------------------------------------
    Description: 
As described in the documentation you can use [camel-cxfrs as 
producer|https://github.com/apache/camel/blob/39c0d63d923bfe9236834ecb1c4470bb7e9e7eaa/components/camel-cxf/src/main/docs/cxfrs-component.adoc#how-to-configure-the-rest-endpoint-in-camel].
 You have some approaches like using a proxy created from a interface which 
maps all the services available in the targeted REST web service (sample 
[here|https://github.com/willianantunes/honesto-sqn/blob/d4bf48257fc64a4725894c7f07c24bb1a516d410/src/main/java/br/com/willianantunes/serenata/JarbasAPI.java#L14]).
 As I'm using Spring Boot and Apache Camel I may create a bean through XML or 
programmatically.
h4. Creating the test sample

I'm testing with the following:

[https://gist.github.com/willianantunes/58979bfb91ee30c7ff4e235940e60880]

You can find a copy of JarbasAPI 
[here|https://github.com/willianantunes/honesto-sqn/blob/d4bf48257fc64a4725894c7f07c24bb1a516d410/src/main/java/br/com/willianantunes/serenata/JarbasAPI.java#L14].
h4. When rsClient producer works as expected

When I do using the first approach using the configuration below everything 
works fine:
{code:xml}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans";
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
       xmlns:cxf="http://camel.apache.org/schema/cxf";
       xmlns:jaxrs="http://cxf.apache.org/jaxrs";
       xmlns:util="http://www.springframework.org/schema/util";
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/util 
http://www.springframework.org/schema/util/spring-util.xsd
       http://camel.apache.org/schema/cxf 
http://camel.apache.org/schema/cxf/camel-cxf.xsd
       http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
       http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring.xsd";>

    <cxf:rsClient id="serviceEndpointViaXML"
                  address="https://jarbas.serenata.ai"; 
                  serviceClass="br.com.willianantunes.serenata.JarbasAPI"/>
</beans>
{code}
h4. When rsClient producer does not work as expected

XML works fine, but when I do the same thing programmatically it doesn't.
{code:java}
    @Bean("serviceEndpoint")
    public SpringJAXRSClientFactoryBean serviceEndpoint() {

        SpringJAXRSClientFactoryBean clientFactoryBean = new 
SpringJAXRSClientFactoryBean();
        clientFactoryBean.setAddress("https://jarbas.serenata.ai";);
        clientFactoryBean.setServiceClass(JarbasAPI.class);

        return clientFactoryBean;
    }
{code}
Although it has no difference compared to XML, it does not work.
h4. When does it fail?

Debugging you can see the following:
 * The bean is correctly got 
[here|https://github.com/apache/camel/blob/a4cfea6823d31eacf57489ffffe1ffeead9a256b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsComponent.java#L76]
 is CxfRsComponent.
 * When a message is sent and there is a _to_ command with the URI 
*cxfrs:bean:serviceEndpoint,* I see the message arriving 
[here|https://github.com/apache/camel/blob/a4cfea6823d31eacf57489ffffe1ffeead9a256b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java#L94]
 in CxfRsProducer.
 * The method 
[invokeProxyClient|https://github.com/apache/camel/blob/a4cfea6823d31eacf57489ffffe1ffeead9a256b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java#L103]
 is called.
 * The SpringJAXRSClientFactoryBean which I provided as bean is ignored. A new 
one is created 
[here|https://github.com/apache/camel/blob/834a59910e4b6b8d089e229b39f6c8673e7c3f9a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java#L414]
 and when it arrives to the next line the method invoked is from 
[CxfRsSpringEndpoint|https://github.com/apache/camel/blob/834a59910e4b6b8d089e229b39f6c8673e7c3f9a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsSpringEndpoint.java]
 which uses 
[configurer.ConfigureBean|https://github.com/apache/camel/blob/834a59910e4b6b8d089e229b39f6c8673e7c3f9a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsSpringEndpoint.java#L77]
 that only works with XML.

h4. Versions used
 * Spring Boot: 1.5.12.RELEASE
 * Apache Camel: 2.21.1

h4. Proposal to make it works

The idea obviously is to make both approaches work, maybe merging the 
configuration or as long as the user is providing a custom 
SpringJAXRSClientFactoryBean then making it the standard instead of creating a 
new one for each request as it is available in the CxfRsSpringEndpoint from the 
start.
----
If you want to understand more, read from 
[here|https://gitter.im/apache/apache-camel?at=5b09f7a54eaffb692d5adb43] until 
the [end of 
conversation|https://gitter.im/apache/apache-camel?at=5b0a13cb54ce23136159a2c0] 
on Gitter.

  was:
As described in the documentation you can use [camel-cxfrs as 
producer|https://github.com/apache/camel/blob/39c0d63d923bfe9236834ecb1c4470bb7e9e7eaa/components/camel-cxf/src/main/docs/cxfrs-component.adoc#how-to-configure-the-rest-endpoint-in-camel].
 You have some approaches like using a proxy created from a interface which 
maps all the services available in the targeted REST web service (sample 
[here|https://github.com/willianantunes/honesto-sqn/blob/d4bf48257fc64a4725894c7f07c24bb1a516d410/src/main/java/br/com/willianantunes/serenata/JarbasAPI.java#L14]).
 As I'm using Spring Boot and Apache Camel I may create a bean through XML or 
programmatically. 

h4. Creating the test sample

I'm testing with the following:

https://gist.github.com/willianantunes/58979bfb91ee30c7ff4e235940e60880

You can find a copy of JarbasAPI 
[here|https://github.com/willianantunes/honesto-sqn/blob/d4bf48257fc64a4725894c7f07c24bb1a516d410/src/main/java/br/com/willianantunes/serenata/JarbasAPI.java#L14].

h4. When rsClient producer works as expected

When I do using the first approach using the configuration below everything 
works fine:

{code:xml}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans";
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
       xmlns:cxf="http://camel.apache.org/schema/cxf";
       xmlns:jaxrs="http://cxf.apache.org/jaxrs";
       xmlns:util="http://www.springframework.org/schema/util";
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/util 
http://www.springframework.org/schema/util/spring-util.xsd
       http://camel.apache.org/schema/cxf 
http://camel.apache.org/schema/cxf/camel-cxf.xsd
       http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
       http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring.xsd";>

    <cxf:rsClient id="serviceEndpointViaXML"
                  address="https://jarbas.serenata.ai"; 
                  serviceClass="br.com.willianantunes.serenata.JarbasAPI"/>
</beans>
{code}

h4. When rsClient producer does not work as expected

XML works fine, but when I do the same thing programmatically it doesn't.

{code:java}
    @Bean("serviceEndpoint")
    public SpringJAXRSClientFactoryBean serviceEndpoint() {

        SpringJAXRSClientFactoryBean clientFactoryBean = new 
SpringJAXRSClientFactoryBean();
        clientFactoryBean.setAddress("https://jarbas.serenata.ai";);
        clientFactoryBean.setServiceClass(JarbasAPI.class);

        return clientFactoryBean;
    }
{code}

Although it has no difference compared to XML, it does not work.

h4. When does it fail?

Debugging you can see the following:

* The bean is correctly got 
[here|https://github.com/apache/camel/blob/a4cfea6823d31eacf57489ffffe1ffeead9a256b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsComponent.java#L76]
 is CxfRsComponent.
* When a message is sent and there is a to command with the URI 
cxfrs:bean:serviceEndpoint, I see the message arriving 
[here|https://github.com/apache/camel/blob/a4cfea6823d31eacf57489ffffe1ffeead9a256b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java#L94]
 in CxfRsProducer.
* The method 
[invokeProxyClient|https://github.com/apache/camel/blob/a4cfea6823d31eacf57489ffffe1ffeead9a256b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java#L103]
 is called.
* The SpringJAXRSClientFactoryBean which I provided as bean is ignored. A new 
one is created 
[here|https://github.com/apache/camel/blob/834a59910e4b6b8d089e229b39f6c8673e7c3f9a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java#L414]
 and when it arrives to the next line the method invoked is from 
[CxfRsSpringEndpoint|https://github.com/apache/camel/blob/834a59910e4b6b8d089e229b39f6c8673e7c3f9a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsSpringEndpoint.java]
 which uses 
[configurer.ConfigureBean|https://github.com/apache/camel/blob/834a59910e4b6b8d089e229b39f6c8673e7c3f9a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsSpringEndpoint.java#L77]
 that only works with XML.

h4. Versions used

* Spring Boot: 1.5.12.RELEASE
* Apache Camel: 2.21.1

h4. Proposal to make it works

The idea obviously is to make both approaches work, maybe merging the 
configuration or as long as the user is providing a custom 
SpringJAXRSClientFactoryBean then making it the standard instead of creating a 
new one for each request as it is available in the CxfRsSpringEndpoint from the 
start.

----

If you want to understand more read starts from 
[here|https://gitter.im/apache/apache-camel?at=5b09f7a54eaffb692d5adb43] until 
the [end of 
conversation|https://gitter.im/apache/apache-camel?at=5b0a13cb54ce23136159a2c0] 
on Gitter.


> camel-cxfrs - rsClient does not work programmatically, only with XML
> --------------------------------------------------------------------
>
>                 Key: CAMEL-12541
>                 URL: https://issues.apache.org/jira/browse/CAMEL-12541
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-cxfrs
>    Affects Versions: 2.21.1
>            Reporter: Willian Antunes
>            Priority: Major
>
> As described in the documentation you can use [camel-cxfrs as 
> producer|https://github.com/apache/camel/blob/39c0d63d923bfe9236834ecb1c4470bb7e9e7eaa/components/camel-cxf/src/main/docs/cxfrs-component.adoc#how-to-configure-the-rest-endpoint-in-camel].
>  You have some approaches like using a proxy created from a interface which 
> maps all the services available in the targeted REST web service (sample 
> [here|https://github.com/willianantunes/honesto-sqn/blob/d4bf48257fc64a4725894c7f07c24bb1a516d410/src/main/java/br/com/willianantunes/serenata/JarbasAPI.java#L14]).
>  As I'm using Spring Boot and Apache Camel I may create a bean through XML or 
> programmatically.
> h4. Creating the test sample
> I'm testing with the following:
> [https://gist.github.com/willianantunes/58979bfb91ee30c7ff4e235940e60880]
> You can find a copy of JarbasAPI 
> [here|https://github.com/willianantunes/honesto-sqn/blob/d4bf48257fc64a4725894c7f07c24bb1a516d410/src/main/java/br/com/willianantunes/serenata/JarbasAPI.java#L14].
> h4. When rsClient producer works as expected
> When I do using the first approach using the configuration below everything 
> works fine:
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans";
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>        xmlns:cxf="http://camel.apache.org/schema/cxf";
>        xmlns:jaxrs="http://cxf.apache.org/jaxrs";
>        xmlns:util="http://www.springframework.org/schema/util";
>        xsi:schemaLocation="
>        http://www.springframework.org/schema/beans 
> http://www.springframework.org/schema/beans/spring-beans.xsd
>        http://www.springframework.org/schema/util 
> http://www.springframework.org/schema/util/spring-util.xsd
>        http://camel.apache.org/schema/cxf 
> http://camel.apache.org/schema/cxf/camel-cxf.xsd
>        http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
>        http://camel.apache.org/schema/spring 
> http://camel.apache.org/schema/spring/camel-spring.xsd";>
>     <cxf:rsClient id="serviceEndpointViaXML"
>                   address="https://jarbas.serenata.ai"; 
>                   serviceClass="br.com.willianantunes.serenata.JarbasAPI"/>
> </beans>
> {code}
> h4. When rsClient producer does not work as expected
> XML works fine, but when I do the same thing programmatically it doesn't.
> {code:java}
>     @Bean("serviceEndpoint")
>     public SpringJAXRSClientFactoryBean serviceEndpoint() {
>         SpringJAXRSClientFactoryBean clientFactoryBean = new 
> SpringJAXRSClientFactoryBean();
>         clientFactoryBean.setAddress("https://jarbas.serenata.ai";);
>         clientFactoryBean.setServiceClass(JarbasAPI.class);
>         return clientFactoryBean;
>     }
> {code}
> Although it has no difference compared to XML, it does not work.
> h4. When does it fail?
> Debugging you can see the following:
>  * The bean is correctly got 
> [here|https://github.com/apache/camel/blob/a4cfea6823d31eacf57489ffffe1ffeead9a256b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsComponent.java#L76]
>  is CxfRsComponent.
>  * When a message is sent and there is a _to_ command with the URI 
> *cxfrs:bean:serviceEndpoint,* I see the message arriving 
> [here|https://github.com/apache/camel/blob/a4cfea6823d31eacf57489ffffe1ffeead9a256b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java#L94]
>  in CxfRsProducer.
>  * The method 
> [invokeProxyClient|https://github.com/apache/camel/blob/a4cfea6823d31eacf57489ffffe1ffeead9a256b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java#L103]
>  is called.
>  * The SpringJAXRSClientFactoryBean which I provided as bean is ignored. A 
> new one is created 
> [here|https://github.com/apache/camel/blob/834a59910e4b6b8d089e229b39f6c8673e7c3f9a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java#L414]
>  and when it arrives to the next line the method invoked is from 
> [CxfRsSpringEndpoint|https://github.com/apache/camel/blob/834a59910e4b6b8d089e229b39f6c8673e7c3f9a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsSpringEndpoint.java]
>  which uses 
> [configurer.ConfigureBean|https://github.com/apache/camel/blob/834a59910e4b6b8d089e229b39f6c8673e7c3f9a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsSpringEndpoint.java#L77]
>  that only works with XML.
> h4. Versions used
>  * Spring Boot: 1.5.12.RELEASE
>  * Apache Camel: 2.21.1
> h4. Proposal to make it works
> The idea obviously is to make both approaches work, maybe merging the 
> configuration or as long as the user is providing a custom 
> SpringJAXRSClientFactoryBean then making it the standard instead of creating 
> a new one for each request as it is available in the CxfRsSpringEndpoint from 
> the start.
> ----
> If you want to understand more, read from 
> [here|https://gitter.im/apache/apache-camel?at=5b09f7a54eaffb692d5adb43] 
> until the [end of 
> conversation|https://gitter.im/apache/apache-camel?at=5b0a13cb54ce23136159a2c0]
>  on Gitter.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to