camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruno Dusausoy <>
Subject CXFRS custom response
Date Fri, 27 May 2011 09:37:36 GMT

As previously stated[1] I'm creating a RESTful webservice, defined by this :

public class RestComputationService implements ComputationService {

     public Response compute(Request request) {
         return null;

Request and Response are quite misleading, they are *not* the one found 
in the JAXRS package, they are generated from a schema.

I'd like to handle an exception like I would in CXF, that is something 
like this :

Category cat = (Category) getCategoryDAO().getCategory(id);
   if (cat == null) {
     ResponseBuilder builder =
     builder.entity("<error>Category Not Found</error>");
     throw new WebApplicationException(;

I've read in "Camel in Action" that a possible way to do this is to use 
something similar to this :

public class FailureResponseProcessor implements Processor {
   public void process(Exchange exchange) throws Exception {
     String body = exchange.getIn().getBody(String.class);
     Exception e = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, 
     StringBuilder sb = new StringBuilder();
     sb.append("ERROR: ");
     sb.append("\nBODY: ");

But if I do this with my CXFRS webservice, I get a 
CamelExecutionException caused by a InvalidPayloadException caused 
itself by a NoTypeConversionAvailableException.
Indeed, what I put in the body (that is, a String) cannot be transformed 
to an object of type Response by JAXB.

So, question, how can I return a custom response ?
Can I bypass JAXB and directly access the CXF rsServer in order to 
respond to the client and tell Camel that it doesn't have to do anything 
else - in other words, telling Camel its work is finished for this 
request ?
Am I doing right or is my design completely flawed ?

Bruno Dusausoy
YP5 Software
Pensez environnement : limitez l'impression de ce mail.
Please don't print this e-mail unless you really need to.

View raw message