Skip to main content

Posts

Showing posts from March, 2012

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

CXF-RS Hiding JAXRS Service Endpoints Listing

You may come across a scenario where you want to stop listing of the exposed service from given endpoint. This can be achieved by setting the property " org.apache.cxf.endpoint.private "   to true as shown in following snippet: < jaxrs:server id = "serivceId" address = "/test" > . . . < jaxrs:properties > < entry key = "org.apache.cxf.endpoint.private" value = "true" /> </ jaxrs:properties > </ jaxrs:server > This will stop the listing of the service when url http://server:port/ test is typed in the browser.