camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Narsi Nallamilli <narsi.nallami...@gmail.com>
Subject camel CxfRsProducer not returning appropriate error status codes
Date Wed, 16 Mar 2016 15:10:55 GMT
I have a cxf rest server calling cxf client and the the cxf rs
client(producer) calling another cxf rest server. If the second server
service return response status as 401 the client is converting it to 500 and
sending it to the first server service.

Please help me, the way I can pass back the status code received from second
server service back to first server service through the cxf client.

I could check the code and see the conversion of error in producer,

https://github.com/apache/camel/blob/master/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java

protected CxfOperationException populateCxfRsProducerException(Exchange
exchange, Response response, int responseCode) {
        CxfOperationException exception;
        String uri = exchange.getFromEndpoint().getEndpointUri();
        String statusText = statusTextFromResponseCode(responseCode);
        Map<String, String> headers = parseResponseHeaders(response,
exchange);
        //Get the response detail string
        String copy =
exchange.getContext().getTypeConverter().convertTo(String.class,
response.getEntity());
        if (responseCode >= 300 && responseCode < 400) {
            String redirectLocation;
            if (response.getMetadata().getFirst("Location") != null) {
                redirectLocation =
response.getMetadata().getFirst("location").toString();
                exception = new CxfOperationException(uri, responseCode,
statusText, redirectLocation, headers, copy);
            } else {
                //no redirect location
                exception = new CxfOperationException(uri, responseCode,
statusText, null, headers, copy);
            }
        } else {
            //internal server error(error code 500)
            exception = new CxfOperationException(uri, responseCode,
statusText, null, headers, copy);
        }

        return exception;
    }



--
View this message in context: http://camel.465427.n5.nabble.com/camel-CxfRsProducer-not-returning-appropriate-error-status-codes-tp5779161.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message