Skip to main content

Posts

Showing posts with the label code

CXF-RS adding custom response code

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; } }