gpt4 book ai didi

Python SUDS SOAP 请求到 https 服务 401

转载 作者:太空狗 更新时间:2023-10-29 22:13:59 24 4
gpt4 key购买 nike

我正在尝试使用 SUDS,但一直在试图弄清楚为什么我无法使身份验证(或 https)正常工作。

我尝试访问的服务是通过带有基本摘要身份验证的 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

最佳答案

Suds 提供了两个HttpAuthenticated 类,一个在suds.transport.http 模块中,第二个在suds.transport.https 模块中.您似乎是从 suds.transport.http 实例化的,但是由于您的 URL 是 https://,您可能想尝试 suds.transport.https.HttpAuthenticated

关于Python SUDS SOAP 请求到 https 服务 401,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8697210/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com