I designed a webservice to perform a task if request parameters are OK, or return 401 Unauthorized HTTP status code if request parameters are wrong or empty.
I\'m us
As an alternative to the solution presented by nilesh, you could also use spring class DefaultResponseErrorHandler. You also need to ovveride its hasError(HttpStatus) method so it does not throw exception on non-successful result.
restTemplate.setErrorHandler(new DefaultResponseErrorHandler(){
protected boolean hasError(HttpStatus statusCode) {
return false;
}});