无法通过代理设置连接到 SOAP API [英] Unable to connect to SOAP API with proxy setting

查看:39
本文介绍了无法通过代理设置连接到 SOAP API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用请求和 zeep 库通过 SOAP API 连接到服务器.如果我手动设置互联网代理,我可以连接.但是,我打算在我的脚本中使用代理设置来自动化该过程.我正在使用以下代码块来执行此操作,但出现以下错误.任何人都可以帮助我我在哪里犯了错误?

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?

连接错误:HTTPSConnectionPool(host='xxxl.com', port=443):最大重试次数超过 url:/webservice.php?wsdl(由NewConnectionError(': 建立新连接失败:[WinError 10061] 无法建立连接,因为目标机器主动拒绝它',))

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))

推荐答案

使用您的代理身份验证使用请求处理代理,而不是会话身份验证.使用 user:pass:

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",
}

这篇关于无法通过代理设置连接到 SOAP API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆