The easiest way to always return 200 OK
and Content-Type: application/json
with JAX-RS:
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
@Path("/not-rest")
@Produces("application/json")
public class NotRestBean {
@GET
public Response getSoapStyle() {
String json = "{}"; // build your response here
return Response.ok(json).build();
}
}
Again, I don't recommend to do this. A central part of REST is the Uniform Interface which includes proper response codes.