Strange behavior from HTTP authentication with suds SOAP library

我只是一个虾纸丫 提交于 2019-12-05 07:42:17

The problem seems to be that an urllib2.HTTPError is being raised from a lower level, and its fp attribute is None:

Line 81 in suds.transport.http:

except u2.HTTPError, e:
    if e.code in (202,204):
        result = None
    else:
        raise TransportError(e.msg, e.code, e.fp)

That exception eventually gets passed to line 698 in suds.client where that error.fp.read() line blows up:

def failed(self, binding, error):
    status, reason = (error.httpcode, tostr(error))
    reply = error.fp.read()

I'd suggest monkey-patching the suds.SoapClient class to get the HTTP error code and message. Add these lines before you construct your suds.Client, then run it to see what HTTP error the 7th fetch raises:

class TestClient(suds.client.SoapClient):
    def failed(self, binding, error):
        print error.httpcode, error.args

suds.client.SoapClient = TestClient
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!