首页 > 解决方案 > Spyne - 如何在 SOAP 端点中接受键值对?

问题描述

我正在尝试构建SOAP服务,并且想将以下内容传递给端点。

    <payload>
        <initiation_date>2019-05-17T00:00:00.000</initiation_date>
        <facility_num>123</facility_num>
        <order_num>123</order_num>
    </payload>  

我想要实现的是dict在我的端点中得到一个。

我的端点如下所示:

class SoapService(ServiceBase):

    @rpc(Unicode, Unicode, Unicode, Array(Unicode), _returns=String)
        def soap_service(self, email, password, action, payload):

我在soap_service端点中需要的是:

payload = {
              'initiation_date': '2019-05-17T00:00:00.000',
              'facility_num': '123',
              'order_num': '123'
          }

我如何实现这一目标?

我真的很感激帮助!

标签: pythonweb-servicessoappython-3.6spyne

解决方案


想通了,我只需要将type装饰器中的有效负载更改为AnyDict.

这有效:

@rpc(Unicode, Unicode, Unicode, AnyDict, _returns=String)
        def soap_service(self, email, password, action, payload):

谢谢!


推荐阅读