1

我正在使用 savon 与肥皂网络服务进行通信。这一切都很好,我现在需要将 ruby​​ 代码投入生产,我们必须通过代理服务器。此代理服务器需要身份验证。

所以我的问题是,我怎样才能继续使用 savon 指定代理服务器身份验证详细信息?

一些进一步的信息:

我发现您可以这样指定代理服务器:

client = Savon::Client.new do
  ...
  http.proxy = "http://proxy.example.com"
end 

翻看savon的代码,发现client块中的http变量指的是以下内容:

def http
  @http ||= HTTPI::Request.new
end

不幸的是,通过 HTTPI::Request 的代码,我看不到为代理本身指定身份验证的方法。这是 httpi 请求的代码:https ://github.com/rubiii/httpi/blob/master/lib/httpi/request.rb

明确一点:我不是在尝试进行 HTTP 身份验证,而是在尝试执行代理身份验证。

指定代理服务器时,我收到以下错误,因为我找不到指定代理身份验证凭据的方法:

407“需要代理验证”

提前感谢您的帮助。

4

2 回答 2

3

试试这个:http.proxy = "http://username:password@host:port"

于 2012-06-25T19:52:51.837 回答
1
Managed to resolve it with the following code:

@proxy_path = '<insert your proxy url here>'
@wsdl_path = '<insert your wsdl url here>'

@client = Savon.client do |variable|
    variable.proxy @proxy_path
    variable.wsdl @wsdl_path
end
@client.operations #to list operations
于 2015-03-10T09:59:30.003 回答