You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by santoshjoshi <sa...@gmail.com> on 2011/10/14 15:23:16 UTC
CXFRS and printing out put to XML file
HI,
I just want to write the out put from a REST service to a file . for which
i am using apache CXF and apache camel.
could any one review the below and comment the things i have done wrong as i
am not able to write the output to a file
<br/>
*a) My camel context configuration with apache cxf is as below*
<jaxrs:client address="http://localhost:8080/test/" id="cityServiceClient"
username="test"
password="pwd"
serviceClass="com.santosh.proxy.service.city.CityService">
<jaxrs:features>
<ref bean="loggingFeature" />
</jaxrs:features>
</jaxrs:client>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<package>com.santosh.routes</package>
<routeBuilder ref="cityserviceroutebuilder" />
</camelContext>
b) *MY Proxy service Interface*
@Path(value="/getCities")
public interface CityService {
@POST
@Produces(value="text/xml")
public String getCities(@QueryParam("countrycode") String countryCode);
}
c) * Call to service *
CityService cityService = (CityService)
context.getBean("cityServiceClient");
cityService.getCities("ae");
d)* Camel Routes*
public class CityRoutes extends RouteBuilder {
public void configure() throws Exception {
//ROUTES
from("cxfbean:cityServiceClient")
.to("file://data/xmls/cities?fileName=test.xml");
}
}
Regards,
Santosh
--
View this message in context: http://camel.465427.n5.nabble.com/CXFRS-and-printing-out-put-to-XML-file-tp4902503p4902503.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: CXFRS and printing out put to XML file
Posted by santoshjoshi <sa...@gmail.com>.
Thanks Everyone in this forum,
I got the solution, basically my camel-context configuration was not up to
that mark,
The below configuration solved my problem.
<! -- 4 THE ACTUAL SERVER WHICH WILL GET HIT -->
<jaxrs:server id="restService" depends-on="camelContext"
address="http://REALSERVER.COM/REST/" createdFromAPI="true"
staticSubresourceResolution="true">
<jaxrs:serviceBeans>
<ref bean="servicecity" />
</jaxrs:serviceBeans>
</jaxrs:server>
<bean name="servicecity" id="servicecity"
class="com.santosh.CityServiceImpl" />
<! -- 3 YOUR PROXY CLIENT -->
<cxf:rsClient id="rsClient" address="http://REALSERVER.COM/REST/"
serviceClass="com.santosh.CityServiceImpl"
username="santosh" password="pwd" />
<! -- 1 JAXRS PROXY CLIENT -->
<jaxrs:client id="cityServiceClient" address="http://localhost:8123/REST/"
serviceClass="com.santosh.CityService" username="santosh" password="pwd">
</jaxrs:client>
<! -- 2 YOUR LOCAL SERVER THAT YOU NEED TO HIT, YOUR LOCAL SERVER
-->
<cxf:rsServer id="rsServer" address="http://localhost:8123/REST/"
serviceClass="com.santosh.CityServiceImpl" />
THE STEPS ARE
1) create JAXRS PROXY CLIENT and get it in your have code
CityService cityService = (CityService)
context.getBean("cityServiceClient");
cityService.getCities("INDIA");
2) the above code will call the SERVER (LOCAL)
3) the above step will call YOUR PROXY CLIENT
4) the PROXY CLIENT will call the ACTUAL REAL SERVER
Please correct if i am wrong,
Thanks
Santosh
--
View this message in context: http://camel.465427.n5.nabble.com/CXFRS-and-printing-out-put-to-XML-file-tp4902503p4914796.html
Sent from the Camel - Users mailing list archive at Nabble.com.