tags:

views:

123

answers:

2

Hi

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: " + jsoncallback); 
    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

+1  A: 

Hi

By changing @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) to be @Produces("application/x-javascript")

This has fixed my issue

Thanks Damien

Damo
A: 

Damien TNX, it work for me.

Matic Petek