Does your subscriptionNotification object have the XmlRootElement annotation? While that might seem strange it is required for the JSON marshal/unmarshal.
By the way, why are you lower casing your class names? Brad On Mon, Aug 29, 2016 at 12:19 AM, imranrazakhan <imranrazak...@gmail.com> wrote: > HI, > > I have developed Rest Service using cxfrs component in 2.17.3. GET services > are working fine but however when call POST service and error 415 ( > Unsupported Media Type ) is returned. We have defined Media Type ( > application/json ) > > Error Logs: > > [ main] DefaultCamelContext INFO > Apache > Camel 2.17.3 (CamelContext: camel-1) started in 1.150 seconds > [ qtp792782299-19] JAXRSUtils ERROR No > message body reader has been found for class > com.warid.sns.service.subscriptionNotification, ContentType: > application/json > [ qtp792782299-19] WebApplicationExceptionMapper WARN > javax.ws.rs.WebApplicationException: HTTP 415 Unsupported Media Type > at > org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBody( > JAXRSUtils.java:1313) > at > org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter( > JAXRSUtils.java:824) > at > org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters( > JAXRSUtils.java:787) > at > org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest( > JAXRSInInterceptor.java:212) > > > Route: > > from("cxfrs://http://localhost:9090/notify?resourceClasses=com.warid.sns. > service.ServiceNotificationResource&bindingStyle=SimpleConsumer") > .log( "The message body contains ${body}" ) > .log( "The message body contains ${headers}" ) > .process(new ServiceNotificationProcessor()) > .marshal().json(JsonLibrary.Jackson); > > ResourceClass: > > @Path("/") > public class ServiceNotificationResource { > > @Context > private UriInfo uriInfo; > > public ServiceNotificationResource() > {} > > @POST > @Path("/notifysubscription") > @Consumes(MediaType.APPLICATION_JSON) > public Response createSubscription(subscriptionNotification sn) { > return Response.status(Response. > Status.NO_CONTENT).build(); > } > > @GET > @Path("/getSubscription") > @Produces(MediaType.APPLICATION_JSON) > public subscriptionNotification getSubscription() { > subscriptionNotification sn = new > subscriptionNotification(); > sn.setApplicationName("1"); > sn.setSubscriberAddress("tel:12345678"); > sn.setApplicationName("news"); > sn.setOperation("sub"); > return sn; > } > } > > Processor: > > Message inMessage = exchange.getIn(); > String operationName = inMessage.getHeader( > CxfConstants.OPERATION_NAME, > String.class); > System.out.println("operation name > ==="+operationName); > > if > ("getSubscription".equalsIgnoreCase(operationName)) > { > subscriptionNotification sn = new > subscriptionNotification(); > sn.setApplicationName("1"); > sn.setSubscriberAddress("tel: > 12345678"); > sn.setApplicationName("news"); > sn.setOperation("sub"); > exchange.getOut().setBody(sn); > } else { > > exchange.getOut().setBody( > Response.status(Response.Status.NO_CONTENT).build() ); > } > > > > > > -- > View this message in context: http://camel.465427.n5.nabble. > com/ERROR-No-message-body-reader-has-been-found-for- > class-ContentType-application-json-in-CXF-JAXRS-2-173-tp5786940.html > Sent from the Camel - Users mailing list archive at Nabble.com. >