[ 
https://issues.apache.org/jira/browse/CXF-5316?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13795455#comment-13795455
 ] 

DUCHEOL KIM commented on CXF-5316:
----------------------------------

Hi Sergey.

Thanks for quick response.
I confirm that PreMatching container filters update headers at 2.7.7 & 2.7.6.
Problem is two things.

1. Request isn't forwarded for different method.
    I test it using 'Content-Type' header instead of using PreMatching 
container filters and found that request isn't forwarded to right methods.
    Below is my service bean which has multiple method for Get Request with 
different Consumes annotation.

    @GET
    @Path("/{Id}")
    @Produces("application/v1+json")
    @Consumes("application/v1+json")    
    public Response getPersonById(@Context Request request, @PathParam("Id") 
String id){
        PersonVO personVO = personManager.getPerson(id);
        if ( personVO == null)
                throw new ElementNotFoundException("There isn't a Person that 
has "+id+" Id.Please check and try again.");
        Person person = convertToApiObj(personVO);
        ETagHelper eTagHandler = new ETagHelper(person);
        return helper.generateEntityReadData(request, person, eTagHandler);
        
    }

    @GET
    @Path("/{Id}")
    @Produces("application/v2+json")
    @Consumes("application/v2+json")    
    public Response getPersonById2(@Context Request request, @PathParam("Id") 
String id){
        PersonVO personVO = personManager.getPerson(id);
        if ( personVO == null)
                throw new ElementNotFoundException("There isn't a Person that 
has "+id+" Id.Please check and try again.");
        Person person = convertToApiObj(personVO);
        ETagHelper eTagHandler = new ETagHelper(person);
        return helper.generateEntityReadData(request, person, eTagHandler);
        
    }
    
    When I execute it , getPersonById method is always invoked.
    I think there is a bug on choosing method section.

2. There isn't body writer for above header.
For the above Produces annotaction, I got a below errors at console.

Oct 15, 2013 2:05:02 PM org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor 
writeResponseErrorMessage
WARNING: No message body writer has been found for response class Person.

It seems that CXF can't process above Content-Type ( application/v2+json ) 

Thanks
Ducheol

> REST Overriding request URI doesn't change serviceBeans
> -------------------------------------------------------
>
>                 Key: CXF-5316
>                 URL: https://issues.apache.org/jira/browse/CXF-5316
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.7.6
>            Reporter: DUCHEOL KIM
>            Assignee: Sergey Beryozkin
>
> Hi All.
> I am writing RESTful API code using CXF.
> For the versioning, we plan to implement based on Content-Type header.
> For this, I'm trying to two ways but both of them aren't work.
> 1. Use different Consumes annotation at same class.
>     I try to set different Content-Type at same class, but it always work 
> with one method.
>     @POST
>     @Path("/")
>     @Produces("application/json")
>     @Consumes("application/json; application,v=2")
>     public Response createProjectV2(Person person) {
>     ....
>     }
> ...
>     @POST
>     @Path("/")
>     @Produces("application/json")
>     @Consumes("application/json")
>     public Response createProject(Person person) {
>     ....
>     }
> always "createProject" which has "application/json" on Consumes annotation.
> 2.  Update Request URI at interceptor to use different serviceBean for 
> differnt version.
> public class CommonInInterceptorImpl  implements RequestHandler{
>       public Response handleRequest(Message message , ClassResourceInfo 
> resourceClass) {
> ...
>                               String requestUri = 
> (String)message.get(Message.REQUEST_URI);
>                               String basePath = 
> (String)message.get(Message.BASE_PATH);
>                               
>                               String targetPath = 
> basePath+"ver-"+version+"/"+requestUri.substring(basePath.length());
>                               message.put(Message.CONTENT_TYPE, 
> "application/json;application,v=2");
>                               message.put(Message.REQUEST_URI, targetPath);
> ...
> }
> ....
> Service Bean 1 
> @Path(PersonService.PERSON_SERVICE_URL)
> public class PersonService extends RESTApiHandler{
> ...
> }
> Service Bean 2  ( in different package ) 
> @Path("/ver-2/"+com.tfsm.palette.api.rest.PersonService.PERSON_SERVICE_URL)
> public class PersonService {
> ...
> }
> I update REQUEST_URI at interceptor to redirect request to other serviceBean, 
> but request is processed orginal desired serviceBean.
> ( I expect redirect request to 2nd service Bean , but it always processed at 
> 1st service Bean. )
> I don't know whether 1st approach is correct in JAX RS spec, but I expect 2nd 
> have to be work because it is mentioned at your documentation.
> http://cxf.apache.org/docs/jax-rs-filters.html#JAX-RSFilters-OverridingrequestURI%2Cqueryandheaders
> Could you let me know how we could redirect request to different serviceBean 
> ? 



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to