Unable to connect to SOAP API with proxy setting

断了今生、忘了曾经 提交于 2019-12-10 10:21:30

问题


I'm using requests and zeep library to connect to a server using SOAP API. If I manually set the internet proxy, I can connect. However, I intend to use proxy setting in my script to automate the process. I'm using the following block of code to do that, but I'm getting the error below. Can anyone pls help me where am I making the mistake?

ConnectionError: HTTPSConnectionPool(host='xxxl.com', port=443): Max retries exceeded with url: /webservice.php?wsdl (Caused by NewConnectionError(': Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it',))

from requests import Session
from requests.auth import HTTPBasicAuth  
from zeep import Client
from zeep.transports import Transport

session = Session()
session.proxies = {'http': 'http://abcdef.com:80'}
session.auth = HTTPBasicAuth('username', 'passwd')
client = Client('https://abcxyz.com/webservice.php?wsdl',
    transport=Transport(session=session))

回答1:


Use your proxy authentication to handle the proxy with requests, not the session auth. Set the proxies with user:pass:

proxies = {
    "http": "user:pass@your_proxy:port",
    "https": "user:pass@your_proxy:port",
}


来源:https://stackoverflow.com/questions/47195778/unable-to-connect-to-soap-api-with-proxy-setting

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