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

Comments

  1. 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

Post a Comment

Popular posts from this blog

java.net.SocketException: Connection reset

Hide empty last column from Table/Tree Viewer

Spring: implements interface not working in @Controller