使用Python 2.7.10中的suds-jurko“OverflowError:日期值超出范围”

时间:2015-07-01 12:35:42

标签: python xml soap suds

我正在使用suds-jurko拨打肥皂电话,而且我遇到了一些麻烦。我有很多通话工作,但我的一个通话失败了:

Traceback (most recent call last):
  File "soap.py", line 160, in <module>
    result = client.service.QueryCachePointDetails(cachepoint)
  File "C:\Python27\lib\site-packages\suds\client.py", line 521, in __call__
    return client.invoke(args, kwargs)
  File "C:\Python27\lib\site-packages\suds\client.py", line 581, in invoke
    result = self.send(soapenv)
  File "C:\Python27\lib\site-packages\suds\client.py", line 621, in send
    original_soapenv=original_soapenv)
  File "C:\Python27\lib\site-packages\suds\client.py", line 685, in process_repl
y
    self.method, replyroot)
  File "C:\Python27\lib\site-packages\suds\bindings\binding.py", line 147, in ge
t_reply
    return self.unmarshaller().process(nodes[0], resolved)
  File "C:\Python27\lib\site-packages\suds\umx\typed.py", line 66, in process
    return Core.process(self, content)
  File "C:\Python27\lib\site-packages\suds\umx\core.py", line 46, in process
    return self.append(content)
  File "C:\Python27\lib\site-packages\suds\umx\core.py", line 61, in append
    self.append_children(content)
  File "C:\Python27\lib\site-packages\suds\umx\core.py", line 138, in append_chi
ldren
    cval = self.append(cont)
  File "C:\Python27\lib\site-packages\suds\umx\core.py", line 61, in append
    self.append_children(content)
  File "C:\Python27\lib\site-packages\suds\umx\core.py", line 138, in append_chi
ldren
    cval = self.append(cont)
  File "C:\Python27\lib\site-packages\suds\umx\core.py", line 61, in append
    self.append_children(content)
  File "C:\Python27\lib\site-packages\suds\umx\core.py", line 138, in append_chi
ldren
    cval = self.append(cont)
  File "C:\Python27\lib\site-packages\suds\umx\core.py", line 62, in append
    self.append_text(content)
  File "C:\Python27\lib\site-packages\suds\umx\typed.py", line 133, in append_te
xt
    content.text = self.translated(content.text, known)
  File "C:\Python27\lib\site-packages\suds\umx\typed.py", line 139, in translate
d
    return resolved.translate(value)
  File "C:\Python27\lib\site-packages\suds\xsd\sxbuiltin.py", line 162, in trans
late
    return DateTime(value).value
  File "C:\Python27\lib\site-packages\suds\sax\date.py", line 119, in __init__
    self.value = self.__parse(value)
  File "C:\Python27\lib\site-packages\suds\sax\date.py", line 151, in __parse
    value += datetime.timedelta(microseconds=1)
OverflowError: date value out of range

我相信最后一部分是关键,因为XML包含了这个gem:

<LastStatusUpdateTime>9999-12-31T23:59:59.9999999</LastStatusUpdateTime>

它窒息而且吐出错误。

所以我的问题是:我可以使用suds-jurko删除XML的这个特定部分吗?这是suds-jurko的问题还是XML响应的问题?

提前谢谢!

1 个答案:

答案 0 :(得分:0)

我能用MessagePlugin解决这个问题:

class TimePlugin(MessagePlugin):
  def received(self, context):
        search = context.reply.replace('9999-12-31T23:59:59.9999999', '')
        context.reply = search

然后我稍后给它打电话:

client = Client(url, plugins=[TimePlugin()])

我认为问题在于suds-jurko在这个时候试图增加一微秒而死,但很容易将时间改为其他东西。它只出现在这里,并且只能在特定情况下发生,所以此修复程序现在可以使用。

我最终可能只是减少时间,因此可以正常添加微秒,但仅仅因为出于输出原因我希望它显示为同一时间。