Skip to main content

Posts

Showing posts with the label RS

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

First CXF-RS service with Tomcat web-container

Looking to get started on CXF-RS, well that was what i was looking for and there are load of articles doing however none of them provide sufficient bullet points to make me understand how the control is following are how to debug the application if something is not working. Well that's what i am going to write here. Following are components you need to get started with first CXF-RS: Tomcat Eclipse (or some equivalent IDE) Spring Create a dynamic web project in the eclipse (this is nothing but a simple web project which can deployed and can run when deployed in the web container like Tomcat). Keep your eye on the bold terms featuring in the files... Start will writing the web.xml descriptor file. contextConfigLocation WEB-INF/ deploy-context.xml org.springframework.web.context.ContextLoaderListener CXFServlet CXF Servlet org.apache.cxf.transport.servlet.CXFServlet 1 ...