camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vizaac <viz...@gmail.com>
Subject REST Proxy Service
Date Wed, 01 May 2013 03:24:38 GMT
Hi,

My requirement is to expose a REST service, a mobile device will call my
REST service, my REST will then call either another REST service or any SOAP
web service based on the route configuration. My route can have multiple
<to:uri> segments so that I can even call multiple REST services or soap
services. 

I may need to transform the incoming parameters (headers/body) from mobile
from rest to soap or some other transformation before I can call another web
service from my REST service.

The output of my REST service should be the aggregation result from various
calls that my REST service is making. 

So I have 3 cases. 

1) Call a (single/multiple) REST service(s) from my REST service
2) Call a (single/multiple) SOAP service(s) from my REST service.
3) Call combination of REST or SOAP services from my REST service.

The ExchangePattern should be InOut so that I can respond back with the
aggregated results from various calls.

*So far I have come up with this route:*

<camelContext xmlns="http://camel.apache.org/schema/spring">
     <route id="testme">
       <from uri="cxfrs:bean:rsServer"/>
       <process ref="simpleprocessor"/>
       <to uri="cxfrs:bean:rsClient"/>
     </route>
   </camelContext>
 

*My Exposed Webservice that Mobile device will call:*

<cxf:rsServer id="rsServer" address="http://localhost:9090" 
 	serviceClass="com.test.AdapterLayer.TestRest" />
 
*To invoke other REST services:*

<cxf:rsClient id="rsClient1" address="http://yahoo.com/"
    serviceClass="com.panera.AdapterLayer.TestRest2"
    loggingFeatureEnabled="true" />

  
*simpleprocessor*

	exchange.getIn().setBody(null);
			exchange.getIn().getHeaders().clear();

			//exchange.setPattern(ExchangePattern.InOut);
			exchange.getIn().setHeader(CxfConstants.CAMEL_CXF_RS_USING_HTTP_API,
Boolean.TRUE);
			exchange.getIn().setHeader(Exchange.HTTP_PATH,
"/customerservice/customers/address");
			exchange.getIn().setHeader(Exchange.HTTP_METHOD, "PUT");   
		
			exchange.getIn().setHeader(CxfConstants.CAMEL_CXF_RS_RESPONSE_CLASS,
"com.test.AdapterLayer.TestImpl");


Now my problems are:

1) How do I get this structure work when I want to call multiple webservices
? How will my route look like and how will use aggregation to do some
processing with response from every webservice and finally prepare a final
response that I need to send out.

2) If I don't set 	exchange.getIn().setBody(null); then the entire thing
doesn't work, I get an exception. 

3)  how does this class (com.test.AdapterLayer.TestImpl) helps in response,
is it an unmarshalled object or something? :
exchange.getIn().setHeader(CxfConstants.CAMEL_CXF_RS_RESPONSE_CLASS,
"com.test.AdapterLayer.TestImpl");




--
View this message in context: http://camel.465427.n5.nabble.com/REST-Proxy-Service-tp5731827.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message