Spyne-如何在SOAP端点中接受键值对?

时间:2019-01-28 07:34:29

标签: python web-services soap python-3.6 spyne

我正在尝试构建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'
          }

我该如何实现?

我非常感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

如图所示,我只需要将装饰器中的有效负载type更改为AnyDict

这有效:

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

谢谢!