我已经使用Spyne为我要构建的某些SOAP服务启动了WSGI应用程序。
我对SOAP和Spyne绝对是陌生的,而且似乎无法弄清楚如何将JSON / Python字典返回为XML。这就是我所做的。
class Fruits(ServiceBase):
@rpc(_returns=Iterable(Unicode))
def fruitify(self):
fruits = {"apple" : "1", "orange" : ["2","3","4"]}
return fruits
我认为问题出在我使用_returns
指定的装饰器中。
我试图一次又一次地阅读文档,但无法弄清楚。
我得到的答复是这样的:
<soap11env:Envelope xmlns:soap11env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="lets_fruit">
<soap11env:Body>
<tns:fruitifyResponse>
<tns:fruitifyResult>
<tns:string>apple</tns:string>
<tns:string>orange</tns:string>
</tns:fruitifyResult>
</tns:fruitifyResponse>
</soap11env:Body>
</soap11env:Envelope>
很明显,它没有与values
关联的我的keys
中的任何一个。
有人做过类似的事情并成功地实现了吗?
谢谢!
答案 0 :(得分:0)
想通了。
我只需要将_returns=Iterable(Unicode)
更改为_returns=AnyDict
。
谢谢!