[Soap-Python] JSONP response

Jesper Larsen jla at fcoo.dk
Wed May 15 08:15:31 CEST 2013


Hi Spyne Users

I am currently using Spyne for SOAP communication but I would like to use the JSON protocol as well. And most likely JSONP since the cross-origin resource sharing mechanism (CORS) will (still) exclude a number of browsers and seems somewhat involved to implement. But I can see from the Spyne source code that JSONP support is currently not available in the JSON serializer (spyne.protocol.json).

So what I intend to do is: Subclass JsonDocument. Override __init__ to take an optional callback function (default=None => behaviour as JsonDocument) and override create_out_string so that it optionally (if callback function is not None) wraps the JSON output in:

callback_function_name + '(' + json + ')'

Since I am new to Spyne I wanted to hear whether this sounds like a reasonable approach?

Best regards,
Jesper


More information about the Soap mailing list