我正在尝试使用SUDS,并试图弄清楚为什么我无法获得身份验证工作(或https)。Python SUDS对https服务的SOAP请求401
我试图访问的服务是基于https的基本摘要身份验证。基于调试,它似乎使用http而不是https。但不是很确定我错过了什么。任何线索表示赞赏。
from suds.client import Client
from suds.transport.http import HttpAuthenticated
import logging
logging.basicConfig(level=logging.DEBUG)
logging.getLogger('suds.client').setLevel(logging.DEBUG)
logging.getLogger('suds.transport').setLevel(logging.DEBUG)
logging.getLogger('suds.xsd.schema').setLevel(logging.DEBUG)
logging.getLogger('suds.wsdl').setLevel(logging.DEBUG)
def main():
url = 'https://blah.com/soap/sp/Services?wsdl'
credentials = dict(username='xxxx', password='xxxx')
t = HttpAuthenticated(**credentials)
client = Client(url, location='https://blah.com/soap/sp/Services', transport=t)
print client.last_sent()
if __name__=="__main__":
main()
调试输出:
DEBUG:suds.wsdl:reading wsdl at: https://blah.com/soap/sp/Services?wsdl ... DEBUG:suds.transport.http:opening (https://blah.com/soap/sp/Services?wsdl)
snip ...
File "C:\Python27\Lib\site-packages\suds-0.4-py2.7\suds\reader.py", line 95, in download
fp = self.options.transport.open(Request(url))File "C:\Python27\Lib\site-packages\suds-0.4-py2.7\suds\transport\http.py", line 173, in open
return HttpTransport.open(self, request)File "C:\Python27\Lib\site-packages\suds-0.4-py2.7\suds\transport\http.py", line 64, in open
raise TransportError(str(e), e.code, e.fp)suds.transport.TransportError: HTTP Error 401: Authorization Required
首先正确性......应该只是“摘要式身份验证”而不是“基本摘要式身份验证”。 auth的类型是:'digest'和'basic'。所以我很困惑。 – user9303 2012-01-02 20:55:44