camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem Jiang <willem.ji...@gmail.com>
Subject Re: Calling REST service without using spring
Date Thu, 29 Jan 2015 08:38:06 GMT
Hi,

I don’t think you specify the right CamelContextLifecycle value.
It should be “org.apache.camel.example.servletlistener.MyLifecycle" instead of “main.java.org.apache.camel.example.servletlistener.MyLifecycle”

The server should be accessed from "http://localhost:8080/CONTEXT_PATH/camel/getPak”, CONTEXT_PATH
is the war file name.

--  
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.iteye.com (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem



On January 27, 2015 at 12:23:25 AM, chitra1986 (chitra1986@gmail.com) wrote:
> Hi,
>  
> I am new to camel .When I try to call REST service using camel , I am
> getting null as response.I don't know where I am missing.
> *camel-config.xml:*
>  
>  
>  
>  
>  
>  
>  
>  
> *Web.xml:*
>  
> name
> MyCamel
>  
>  
>  
>  
> routeBuilder-MyRoute
>  
> classpath:camel-config.xml
>  
>  
>  
> CamelContextLifecycle
>  
> main.java.org.apache.camel.example.servletlistener.MyLifecycle  
>  
>  
>  
>  
>  
> org.apache.camel.component.servletlistener.JndiCamelServletContextListener  
>  
>  
>  
>  
> CamelServlet
>  
> org.apache.camel.component.servlet.CamelHttpTransportServlet  
> 1
>  
>  
>  
>  
> CamelServlet
> /camel/*
>  
>  
> *MyLifeCycle.java:*
> public class MyLifecycle implements CamelContextLifecycle {
>  
> public void beforeStart(ServletCamelContext camelContext, JndiRegistry
> registry)
> throws Exception {
> registry.bind("pakBean", new TestRest());
> }
> .....
> }
>  
> TestRest.java:
> public class TestRest
>  
> {
> int status = 0;
> String problemDescription = null;
> String Response=null;
> String details = null;
> String
> URL1="http://localhost:8080/rest/services/token/fetchTest?authMethod=Basic&authUsername=test&authPassword=Test";
 
> public String test(){
> CamelContext camel = new DefaultCamelContext();
> ProducerTemplate template = camel.createProducerTemplate();
> Exchange exchange = template.request(URL1, new Processor() {
> public void process(Exchange exchange) throws Exception {
> exchange.getIn().setHeader(Exchange.HTTP_URI,URL1);
> exchange.getIn().setHeader(Exchange.HTTP_METHOD,"GET");
> exchange.getIn().setHeader(Exchange.AUTHENTICATION,"Basic");
>  
> exchange.getIn().setHeader(Exchange.CONTENT_TYPE,"application/json");
> exchange.getIn().setBody("Hello");
> String uri = exchange.getIn().getHeader(Exchange.HTTP_URI,
> String.class);
> String out = exchange.getIn().getHeader(Exchange.HTTP_METHOD,
> String.class);
> System.out.println("uri:::"+uri);
> System.out.println("out:::"+out);
> }
>  
> });
> Message out = exchange.getOut();//Getting null and it is not hitting
> the service
>  
> }
>  
>  
> }
>  
> Please help me to fix the issue.Thanks in adv.
>  
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/Calling-REST-service-without-using-spring-tp5762125.html
 
> Sent from the Camel - Users mailing list archive at Nabble.com.
>  


Mime
View raw message