cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Josh Holtzman <jholtz...@berkeley.edu>
Subject JSONP interceptors
Date Sun, 29 Aug 2010 02:12:00 GMT
With some help from sergeyb and dkulp yesterday, I wrote some very simple
CXF interceptors that enable transparent JSONP capabilities in JAX-RS.  If a
request contains a "jsonp" parameter in the querystring, and the response's
content type is "application/json", the response is wrapped in the callback
specified by the jsonp parameter.

For example, a response from a hypothetical JAX-RS endpoint at /foo.json
looks like this:

{"foo":"bar"}

The response to the same URL with a jsonp parameter
(/foo.json?jsonp=handleCallback) would look like this:

handleCallback({"foo":"bar"})

With jsonp, the /foo.json service can be called from 3rd party browser-based
mashups.  Without it, browsers' same-origin policy limits the usefulness of
the endpoint.  If there is interest in including this functionality in CXF
itself, I'd be happy to submit a patch.

Thanks,
Josh

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message