I have a simple web service written with Apache Wink 1.0, I want to receive and return JSON data.
According the Wink docs, this should work …
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public JSONObject postJSON(JSONObject requestJSON) {
JSONObject jobj = new JSONObject();
return jobj;
}
… but I see this error when I try to hit the web service …
org.apache.wink.server.internal.handlers.PopulateResponseMediaTypeHandler -
Content-Type not specified via Response object or via @Produces annotation
so automatically setting via generic-type compatible MessageBodyWriter providers
… any advice or suggestions are greatly appreciated!
Rob
Usage of JSONObject is a little bit strange. Easier and more flexible approach:
JAX-RS would serialize MyDto do JSON. In fact, even cleaner approach is to return Response object