【发布时间】:2018-12-26 07:59:15
【问题描述】:
我已经使用 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。
以前有没有人做过类似的事情并成功实现过?
提前致谢!
【问题讨论】:
标签: python python-3.x soap spyne