camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Seumas Soltysik <seu...@soltysik.com>
Subject Re: Configuring a CXFRS client used in a Camel route with Proxy server
Date Mon, 15 Aug 2011 07:34:17 GMT
Thanks, I will give it a try and let you know what I find.
Regards,
Seumas

On Aug 15, 2011, at 2:52 AM, Willem Jiang wrote:

> Hi Seumas,
>
> Can you try to change the code of getBus() == null to bus == null ?
> That is how I fix the issue of CXF-3734, as the getBus() will return  
> a default bus to use.
>
>
> On 8/15/11 2:29 PM, Seumas Soltysik wrote:
>> Hi Willem,
>> I am using a version of Camel 2.1.x and CXF 2.2.x.
>>
>> I am simply using the CxfRsRouterTest in Camel and modifying the
>> CxfRsSpringRouter.xml file to test the ability to set proxy server
>> values on the HTTP conduit.Adding the import statement as suggested  
>> does
>> not seem to help as it creates additional problems, specifically
>> associated with registering the correct DestinationManagers with the
>> Bus. If you add the import statement to this test you will see what  
>> I mean.
>>
>> If you look at the CxfRsClientFactoryBeanDefinitionParser in Camel  
>> 2.1
>> you will see the following code:
>>
>> public void setApplicationContext(ApplicationContext ctx) throws
>> BeansException {
>> if (getBus() == null) {
>> // Don't relate on the DefaultBus
>> BusFactory factory = new SpringBusFactory();
>> Bus bus = factory.createBus();
>> BusWiringBeanFactoryPostProcessor.updateBusReferencesInContext(bus,  
>> ctx);
>> setBus(bus);
>> }
>> }
>>
>> The intent of this code is to add information from the application
>> context used to create the camel route to configure the bus used in  
>> the
>> CxfRs client, therefore allowing a user to add Bus configuration  
>> code to
>> the camel spring configuration file. The problem is that the call to
>> getBus() does not return null as a default bus has already been  
>> injected
>> as a result of an @Resource annotation at the base class level.
>>
>> If I could create a situation where the @Resource annotation was
>> over-ridden and the call to getBus() returned null, then I think all
>> would be well. Of course I am not sure what the side of effect of  
>> doing
>> this would be on other code.
>>
>> Regards,
>> Seumas
>>
>> On Aug 14, 2011, at 11:41 PM, Willem Jiang wrote:
>>
>>> Hi Seumas,
>>>
>>> Which version of Camel and CXF are you using?
>>>
>>> I just fixed CXF-3734[1] last week.
>>> You may work around this issue by using the include resource like  
>>> this
>>> in you camel route configuration.
>>>
>>> <import resource="classpath:META-INF/cxf/cxf.xml"/>
>>> ...
>>>
>>> [1]https://issues.apache.org/jira/browse/CXF-3734
>>>
>>>
>>> On Mon Aug 15 02:31:00 2011, Seumas Soltysik wrote:
>>>> Here is my question: How do I configure a cxfrs client in Camel  
>>>> route to
>>>> be able to converse with a proxy server blocking access to a JAXRS
>>>> endpoint?
>>>>
>>>> I have done a fair bit of investigation into this and here is  
>>>> what I
>>>> have as background information:
>>>>
>>>> I have a route which routes to JAXRS endpoint that looks  
>>>> something like
>>>> this:
>>>>
>>>>
>>>> <!-- Defined the server endpoint to create the cxf-rs consumer -->
>>>> <cxf:rsServer id="rsServer" address="http://localhost:9000"
>>>> serviceClass 
>>>> ="org.apache.camel.component.cxf.jaxrs.testbean.CustomerService"
>>>>
>>>> />
>>>>
>>>> <!-- Defined the client endpoint to create the cxf-rs consumer -->
>>>> <cxf:rsClient id="rsClient" address="http://localhost:9002"
>>>> serviceClass 
>>>> ="org.apache.camel.component.cxf.jaxrs.testbean.CustomerService"/>
>>>>
>>>>
>>>>
>>>> <!-- The camel route context -->
>>>> <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring

>>>> ">
>>>> <route>
>>>> <from uri="cxfrs://bean://rsServer"/>
>>>> <to uri="cxfrs://bean://rsClient"/>
>>>> </route>
>>>> </camelContext>
>>>>
>>>> However, the remote host is blocked by a Proxy server. Therefore  
>>>> I need
>>>> to configure the cxfrs producer/client to talk to a Proxy server.  
>>>> If
>>>> this was a standalone JAXRS client I would simply add this  
>>>> configuration
>>>> element to the spring.xml used to configure the CXF bus used by the
>>>> JAXRS client:
>>>>
>>>> <http-conf:conduit name="*.http-conduit">
>>>> <http-conf:client ProxyServer="remote_host"  
>>>> ProxyServerPort="9090"/>
>>>> </http-conf:conduit>
>>>>
>>>> However, adding this to the spring config used to initialize the  
>>>> Camel
>>>> ApplicationContext has no effect since a default bus is created  
>>>> during
>>>> the creation of the rsClient bean which does not have access to any
>>>> configuration information in the Camel application context. From  
>>>> the
>>>> schema for the cxfrs client, it appears that I can use the bus  
>>>> attribute
>>>> to set my own bus(documentation is unclear on this point),  
>>>> however, this
>>>> does not provide me with a simple solution as even if I define my  
>>>> own
>>>> <cxf:bus> element to inject into the cxfrs client, I still have  
>>>> to be
>>>> able to add the policy/config information to the bus for the  
>>>> client to
>>>> use. To do this it looks like I would have to create my own CXF  
>>>> Feature
>>>> to perform this injection and then set this Feature on the  
>>>> <cxf:bus>
>>>> element.
>>>>
>>>> Is there another solution that I am missing to be able to connect a
>>>> cxfrs client in a camel route to a proxy server?
>>>>
>>>> Regards,
>>>> Seumas
>>>
>>>
>>>
>>> --
>>> Willem
>>> ----------------------------------
>>> FuseSource
>>> Web: http://www.fusesource.com
>>> Blog: http://willemjiang.blogspot.com (English)
>>> http://jnn.javaeye.com (Chinese)
>>> Twitter: willemjiang
>>> Weibo: willemjiang
>>>
>>> --
>>> Willem
>>> ----------------------------------
>>> FuseSource
>>> Web: http://www.fusesource.com
>>> Blog: http://willemjiang.blogspot.com (English)
>>> http://jnn.javaeye.com (Chinese)
>>> Twitter: willemjiang
>>> Weibo: willemjiang
>>>
>>
>>
>
>
> -- 
> Willem
> ----------------------------------
> FuseSource
> Web: http://www.fusesource.com
> Blog:    http://willemjiang.blogspot.com (English)
>         http://jnn.javaeye.com (Chinese)
> Twitter: willemjiang
> Weibo: willemjiang
>


Mime
View raw message