Following snippet show how to return the custom Response code as http response code while returning the response:
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
@Path("/")
@Consumes("application/xml")
@Produces("application/xml")
public class Test {
public Test () {
}
@POST
public Response test() {
Response response = Response.status(4xx).entity("Testing").build();
return response;
}
}
Well this is very simple and straighfwd. any idea abt setting the response code reason, I have debugged and searched quite a bit, but it looks CXF does not support this.
ReplyDelete