Hi The reason a WADL fragment is virtually empty is that Response is returned and as far as the WADLGenerator is concerned it can not get any useful info out of it. Also, it is not possible to show individual status codes which may be set by the application code in the java-first case. Only having @Oneway annotations would result in WADL showing 202 status You may want to try using @Description annotation to describe that a given method may return a number of status codes.
cheers, Sergey On Wed, Jun 9, 2010 at 8:40 AM, Sunil Dhage <[email protected]>wrote: > Hi, All the members of the users list, > > I am a newbie to the users list and my issue is regarding exception > handling in Rest web services. > > I am trying to handle exceptions in my Resource methods as mentioned in > http://cxf.apache.org/docs/jax-rs.html#E > My code is > > @Path("allEmployees/{noOfEmps}") > @GET > @Produces("application/xml") > public Employees getAllEmployees(int noOfEmps) { > if (noOfEmps == 0){ > throw new WebApplicationException(403); > } > return null; > } > > @Path("addEmployees/{empId}") > @PUT > public Response addEmployees(int empId){ > if (empId == 0){ > return Response.status(403).build(); > } > return Response.ok().build(); > } > > When I test using my browsers neither of the service methods come with the > response code 403. > And when I generate my wadl by http://<host>/app/....?_wadl<http:// > %3chost%3e/app/....?_wadl>, > ....... > <method name="GET"> > <request></request> > <response> > <representation mediaType="application/xml"/> > </response> > </method> > ..... > But it should show different response entries like > > <response status ="403"> > ... > </response> > <response status = "200"> > .. > </response> > > Then I tried mapping the exceptions as below > > @Provider > public class ExceptionMapperProvider implements > ExceptionMapper<WebApplicationException> { > public Response toResponse(WebApplicationException ex) { > return Response.status(ex.getResponse().getStatus()). > entity(ex.getMessage()). > type("text/plain"). > build(); > } > } > > And registered this provider with the <jaxrs:providers> in my cxf.xml. > > Still I am neither > getting the response with status code 403 > nor > WADL containing different response status codes. > > Please help me in finding what am I missing out here. > > Regards, > Sunil Kumar Dhage. >
