jersey webservice not returning jsonp
I am trying to create a webservice that will return jsonp. At the moment it is only returning json
Here is my code:
@Path("/jsonp")
public class JsonpWebservice {
@GET
@Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
public JSONWithPadding readAllP(@QueryParam("jsoncallback") @DefaultValue("jsoncallback") String jsoncallback)
{
ToolKitBean tkBean = new ToolKitBean();
tkBean.setNegativeCount("10");
tkBean.setPositiveCount("11");
System.out.println("jsoncallback: " + jsoncallba开发者_C百科ck);
return new JSONWithPadding( new GenericEntity<ToolKitBean>(tkBean) {}, jsoncallback);
}
}
i also have a JAXBContext resolver defined.
When i look at the response from this webservice, I see the json and not jsonp - {"negativeCount":"10","positiveCount":"11"}
Any ideas what I need to do in order to have jsonP returned from this webservice?
Thanks DAmien
By changing @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) to be @Produces("application/x-javascript")
This has fixed my issue
Thanks Damien
精彩评论