【问题标题】:Using suds for python as a SOAP client and failing to handle NoneType使用 suds for python 作为 SOAP 客户端并且无法处理 NoneType
【发布时间】:2015-12-30 21:18:41
【问题描述】:

所以我在 python3 中使用 suds-jurko,我的请求中有这样的值:

`Date = None`

日期不是必填字段。我遇到的问题是当它处理请求时,我得到了错误:

WebFault: Server raised fault: 'The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://webservices.soapclient.com/v11:request. The InnerException message was 'There was an error deserializing the object of type WebServices.Posting.Request. The value '' cannot be parsed as the type 'DateTime'.'. Please see InnerException for more details.'

任何线索我可以传递一个有效的 NoneType 以便我的客户不会将其转换为空字符串?

【问题讨论】:

    标签: c# python web-services soap


    【解决方案1】:

    如果日期字段是可选的,您应该完全跳过它,并且根本不尝试传递任何值(即使它设置为 NoneType)。

    【讨论】:

    • 我的建议是在调用client.service.soap_method(arg1 = x, arg2 = y, arg3 = z) 时使用命名参数,而不是将可选参数作为参数传递。
    • 如果您在使用复杂类型时遇到此问题,我还遇到了这个可能有帮助的相关问题:stackoverflow.com/questions/9388180/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多