Acácio Centeno <acaciocent...@gmail.com> writes:

> Hi, I've searched both this group and the web but was unable to find an 
> answer, sorry if it has already been answered, it seems such a common problem 
> that I am sure someone has asked before.
>
> We have a WebServices platform that must reply in XML, JSON, or JSONP. Having 
> to convert between these formats is a really pain in the neck.
>
> What I would like to do is, given some schema representation, that could be a 
> DTD, XSD or whatever and a python dictionary with the values for each node, 
> generate the output in either XML, JSON or JSONP.

You could have a look at the PyPI packages "dm.zope.rpc"
and "dm.zope.rpc.wsdl_suds". They provide a middleware
to support protocol independent web services (for the
"Zope" application server). Together, they support
XML-RPC, JSON-RPC and WSDL decribed SOAP web services.
As you are likely not using Zope, you probably cannot use
these packages directly but you may get some ideas how
to create such a middleware for your web framework.

Python (from 2.6 on) has "json" support. Thus converting
a dict to "json" is simple ("json.dumps").

"dm.zope.rpc.wsdl_suds" abuses "suds" to parse the WSDL
and generate appropriate SOAP responses from a dict.
Alternatively, you might use "PyXB" for that.

You could also have a look at "Spyne" (formerly known (among others)
as "rpclib"). I think (but am not sure) that it targets
your use case for the "twisted" environment.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to