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:*
<routes xmlns="http://camel.apache.org/schema/spring";>

        <route id="fromServlet">
                <from uri="servlet:///getPak" />

                        <to uri="bean:pakBean"/> 
        </route> 

*Web.xml:*
<context-param>
    <param-name>name</param-name>
    <param-value>MyCamel</param-value>
  </context-param>

   
  <context-param>
    <param-name>routeBuilder-MyRoute</param-name>
    
    <param-value>classpath:camel-config.xml</param-value>
  </context-param>
  <context-param>
     
    <param-name>CamelContextLifecycle</param-name>
   
<param-value>main.java.org.apache.camel.example.servletlistener.MyLifecycle</param-value>
  </context-param>

   
   <listener>
   
<listener-class>org.apache.camel.component.servletlistener.JndiCamelServletContextListener</listener-class>
  </listener>

  
  <servlet>
    <servlet-name>CamelServlet</servlet-name>
   
<servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

   
  <servlet-mapping>
    <servlet-name>CamelServlet</servlet-name>
    <url-pattern>/camel/*</url-pattern>
  </servlet-mapping> 

*MyLifeCycle.java:*
public class MyLifecycle implements CamelContextLifecycle<JndiRegistry> {

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.

Reply via email to