0 Replies Latest reply on Dec 1, 2011 1:07 PM by Fernando Salceda

    CXFRS Resource and JacksonJsonProvider

    Fernando Salceda Novice

      Hi, Im using fuse-esb-4.4.1-fuse-01-06 and trying to implement de following camel route consuming from a cxfrs endpoint which consumes JSON. But I get " No message body writer has been found for response class ACSCategory" and " No message body reader has been found for request class ACSCategory" depending on method I call. I think I have to register the JacksonJsonProvider or annotate de resource class, but don't know how! How can I manage it?

       

      My resourceClass is:

      -


       

      ublic class ACSCategory {

       

           String id = "idvalue";

           String name = "namevalue";

            

           public String getId() {

                return id;

           }

           public void setId(String id) {

                this.id = id;

           }

           public String getName() {

                return name;

           }

           public void setName(String name) {

                this.name = name;

           }

            

      }

      -


       

       

      My RouteBuilders configure method is:

       

      -


       

           public void configure() throws Exception {

       

                from("cxfrs://http://0.0.0.0:9009?resourceClasses=" + ACSResource.class.getName())

                    .process(new Processor() {

                          

                         public void process(Exchange exchange) throws Exception {

                              

                          Message inMessage = exchange.getIn();                       

                          String operationName = inMessage.getHeader(CxfConstants.OPERATION_NAME, String.class);

                           

                          if ("get".equals(operationName)) {

                               String id = (String) inMessage.getBody(String.class);

                              log.info("OPERATION INVOKED: %GET%"id"%");

                              ACSCategory category = new ACSCategory();

                              category.setId(""+id);

                              category.setName("nameValueFor"+id);

                              exchange.getOut().setBody(category);

                              //inMessage.setBody(category);

                          } else if ("search".equals(operationName)) {

                               log.info("OPERATION INVOKED: %SEARCH%");

                                ACSCategory category1 = new ACSCategory();

                                category1.setId("idvalue1");

                                category1.setName("idvalue1");

                                ACSCategory category2 = new ACSCategory();

                                category2.setId("idvalue2");

                                category2.setName("idvalue2");

                                ArrayList();

                                categories.add(category1);

                                categories.add(category2);

                                inMessage.setBody(categories);

                          } else if ("create".equals(operationName)) {

                               log.info("OPERATION INVOKED: %CREATE%");

                               Response r = Response.status(200).entity("CREATE OK!!").build();

                               inMessage.setBody(r);

                          } else if ("update".equals(operationName)) {

                               log.info("OPERATION INVOKED: %UPDATE%");

                               Response r = Response.status(200).entity("UPDATE OK!!").build();

                               inMessage.setBody(r);

                          } else if ("delete".equals(operationName)) {

                               String id = (String) inMessage.getBody(String.class);

                              log.info("OPERATION INVOKED: %DELETE%"id"%");

                               Response r = Response.status(200).entity("DELETE OK!!").build();

                               exchange.getOut().setBody(r);

                               //inMessage.setBody(r);

                          }

                   

                        }

       

                   });

          }

      -


       

       

      My bundle plugin configuration and dependencies in pom.xml are:

       

             

       

      -


       

      And my camel context configuration:

       

           

       

       

      Hope there is enough info to know what I'm forgiving or doing wrong. Thx.

       

      Fernando.