Hi

This issue looks similar to the one reported recently, but in this case it is quite obvious that CXF JAX-RS runtime gets the wrong portion of the Request URI, specifically, the root resource can match "myservice/users" but what it gets is "cxf-rest-example/myservice/users", which also includes a 'context', "cxf-rest-example" - as far as I recall it is not an issue when using Camel Servlet..., I guess in this setup the component does not really know which portion of the request URI constitutes a context

Can you do

<from uri="http://localhost:8080/myservice/users"; />

This will probably 'fix' it, or have

<from uri="http://localhost:8080/example/myservice/users"; />

@Path("/example/myservice/")
@Produces("application/xml")
public class ServiceImpl implements ServiceDefn

HTH, Sergey

On 18/04/13 14:52, abhi wrote:
Hi,
I have written CXF REST web service which I am calling through my camel
route as follows

/       
      <camel:camelContext xmlns="http://camel.apache.org/schema/spring";>        
        <route id="RestRoute">
                <from uri="http://localhost:8080/cxf-rest-example/myservice/users"; 
/>
          <to uri="bean:myBean?method=myMethod"/>
        </route>
     </camel:camelContext>/
        
these are 2 different projects
cxf-rest-example - for CXF web service
Camel-First - Project for camel 
        
My code look as below

        
*serviceimpl.java*

        
        package service;

import java.util.HashMap;
import java.util.Map;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;

import pojo.User;
import pojo.UserCollection;
        
        @Path("/myservice/")
        @Produces("application/xml")
        public class ServiceImpl implements ServiceDefn {

     private static Map<Integer, User>  users = new HashMap<Integer, User>();

     static {
         users.put(1, new User(1, "foo"));
         users.put(2, new User(2, "bar"));
         users.put(3, new User(3, "baz"));
     }

     public ServiceImpl() {
     }

     @GET
     @Path("/users")
     @Override
     public UserCollection getUsers() {
         return new UserCollection(users.values());
     }

        
Above route is succesfully calling my web service.

But when I am trying to call it using following route, my web service is not
getting called. Can anybody tell what can be issue.

        <camel:camelContext xmlns="http://camel.apache.org/schema/spring";>
        <route id="RestRoute">
                <from uri="stream:in?promptMessage=Enter Something:"/>
                <from uri="cxfrs://bean://rsServer"/>   
                <to uri="cxfrs://bean://rsClient"/>
                <setHeader headerName="CamelCxfRsUsingHttpAPI">
             <constant>false</constant>
         </setHeader>
          <to uri="bean:myBean?method=myMethod"/>
        </route>
        </camel:camelContext>
        
        <bean id="myBean" class="org.test.MyBean" />
        
        <cxf:rsServer id="rsServer"
address="http://localhost:8080/cxf-rest-example/myservice/users";
               serviceClass="service.ServiceImpl"/>

        <cxf:rsClient id="rsClient"
address="http://localhost:8080/cxf-rest-example/myservice/users";
               serviceClass="service.ServiceImpl"/>
                
                
When I ran above route i get following logs :

Apr 18, 2013 7:09:50 PM org.apache.cxf.endpoint.ServerImpl initDestination
INFO: Setting the server's publish address to be
http://localhost:8080/cxf-rest-example/myservice/users
2013-04-18 19:09:50.956:INFO:oejs.Server:jetty-7.5.4.v20111024
2013-04-18 19:09:50.985:INFO:oejs.AbstractConnector:Started
SelectChannelConnector@localhost:8080 STARTING
2013-04-18 19:09:51.056:INFO:oejsh.ContextHandler:started
o.e.j.s.h.ContextHandler{/cxf-rest-example/myservice,null}
Enter Something:abc
Apr 18, 2013 7:09:56 PM org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor
processRequest
WARNING: No root resource matching request path
/cxf-rest-example/myservice/users has been found, Relative Path: /. Please
enable FINE/TRACE log level for more details.
Enter Something:xxxx
Apr 18, 2013 7:10:03 PM org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor
processRequest
WARNING: No root resource matching request path
/cxf-rest-example/myservice/users has been found, Relative Path: /. Please
enable FINE/TRACE log level for more details.
Enter Something:


Thanks,
Abhi



--
View this message in context: 
http://camel.465427.n5.nabble.com/Issue-in-Calling-REST-web-service-through-Camel-tp5731079.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Reply via email to