Am new to RESTful web services. I wrote a web service method and am currently returning an XML by using @Produces(MediaType.TEXT_XML)
. But the requirement is that my web service method must return an Integer instead of XML. How can I achieve this? kindly help me with this. Below is the method I wrote.
@Path("{type}/{token}")
@GET
@Produces(MediaType.TEXT_XML)
public String setToken(@Context HttpServletRequest request, @Context HttpServletResponse response, @PathParam("type") String type, @PathParam("token") String token) throws ServletException, IOException {
String value=token;
if(request==null){
System.out.println("Request null");
}
System.out.println("Token: " + value);
System.out.println("AnumLotnum: " + type);
if(request!=null){
request.setAttribute("param", value);
request.getRequestDispatcher("/dummy").include(request, response);
}
String id=request.getAttribute("ID").toString();
return "<token>"+ "<value>"+id+"</value>" + "</token>";
}