camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cephy <p...@logix.co.nz>
Subject Help using CXFRS client proxy to call RESTful services
Date Tue, 11 Sep 2012 10:44:12 GMT
Hi guys,

I am relatively new to Camel - yet most aspects have gone rather well so far
:-)
However, I need some help with the "client proxy" method to call a CXFRS
producer using camel 2.9.0

I have coded a class model with appropriate annotations and declared the
services in Blueprint XML as listed at end of this post. It all works
perfectly, serving up RESTful services that I can call with SoapUI.

Now I want a camel processor to call one of the exposed RESTful services
using the "client proxy" method.
I have read the documentation for the CXFRS component
(http://camel.apache.org/cxfrs.html) under "How to invoke the REST service
through camel-cxfrs producer".  However, I cannot see how I apply the given
example to calling my services as a camel producer.

I've tried adapting the "client proxy" example to my case:

	ProducerTemplate template = context.createProducerTemplate();
	Exchange exchange = template.send("cxfrs:bean:myServer", new Processor() {
		...follow the example...
	});
	MyOperationResuly result =
exchange.getOut().getBody(MyOperationResult.class);
	
...however this doesn't call the service, and all I get is a null result.

I can successfully call the service directly using the following code...

	MyService service =
JAXRSClientFactory.create("http://localhost:8181/cxf/MyService",
MyService.class);
	MyOperationResult result =
service.onMyOperation("MyOperationParameterString");

How do I actually call my services using the CXFRS "client proxy" method??

Maybe I have to do more in my Blueprint config file??
I've seen Spring config files using both cxf:rsServer and cxf:rsClient
declarations - but I haven't seen an equivalent Blueprint example.

Any assistance to get me back on track would be most appreciated.

Cheers,
Paul.

--------------

My blueprint.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<blueprint 
	xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
	xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xmlns:jaxrs="http://cxf.apache.org/blueprint/jaxrs"
	xmlns:camel="http://camel.apache.org/schema/blueprint"
	xsi:schemaLocation="
		http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
		http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0
http://svn.apache.org/repos/asf/aries/trunk/blueprint/blueprint-cm/src/main/resources/org/apache/aries/blueprint/compendium/cm/blueprint-cm-1.1.0.xsd
		http://cxf.apache.org/blueprint/jaxrs
http://cxf.apache.org/schemas/blueprint/jaxrs.xsd
		http://camel.apache.org/schema/blueprint
http://camel.apache.org/schema/blueprint/camel-blueprint.xsd" >

	
	<jaxrs:server 
		id="myServer" 
		address="/MyService" >
		<jaxrs:providers>
			<bean class="org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider" />
		</jaxrs:providers>
		<jaxrs:serviceBeans>
			<ref component-id="myService" />
		</jaxrs:serviceBeans>
	</jaxrs:server>
	<bean id="myService" class="org.me.MyService" />

	
	<camelContext xmlns="http://camel.apache.org/schema/blueprint"
id="my-camel-context" >
		<routeBuilder ref="myServiceRouteBuilder" />
	</camelContext>
	<bean id="myServiceRouteBuilder" class="org.me.MyServiceRouteBuilder" />

</blueprint>




--
View this message in context: http://camel.465427.n5.nabble.com/Help-using-CXFRS-client-proxy-to-call-RESTful-services-tp5719108.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message