Q: how to convert the post request from xml to json in a restful web service @POST    
@Path("/users")
@Produces(MediaType.APPLICATION_XML)
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public String createUser(@FormParam("id") int id,
@FormParam("name") String name,
@FormParam("profession") String profession,
@Context HttpServletResponse servletResponse) throws IOException{
User user = new User(id, name, profession);
int result = userDao.addUser(user);
if(result == 1){
return SUCCESS_RESULT;
}
return FAILURE_RESULT;
}

strong text
reference : https://www.tutorialspoint.com/restful/restful_methods.htm

A: Produces and consumes are the sharing content-Type and Accept headers.
You can go ahead and get the input as application/Json.
But i will give you the conversion of XML to JSON
Load the XML with jaxb
Catalog catalog = JAXB.unmarshal(new File(xmlFile), Catalog.class);

Now you have to serialize the java object 
ObjectMapper mapper = new ObjectMapper();
mapper.writeValue(System.out, catalog);

You are done.!

A: If you want to return a value as JSON please remove the
        @Produces(MediaType.APPLICATION_XML)
And use         @Produces(MediaType.APPLICATION_JSON)
instead of XML. In default media type is always a JSON
But in your code, you are returning a STRING value which is not at all a JSON. If you insist to return a string value please use            @Produces(MediaType.APPLICATION_JSON_VALUE)
    it will return a String equivalent of MediaType.APPLICATION_JSON.

A: Use         
@Produces(MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON) 
    at method level

and use 
@XMLRootElement

at pojo class level
