我需要使用 Heroku 的 IP 白名单访问服务,因此需要 HTTP 代理。
我配置了 Proximo 插件,并且有一个看起来差不多的代理 urlhttp://proxy:secret-key@proxy-0-0-0-0.proximo.io
在 Savon,我尝试像这样配置代理:
client = Savon.client(wsdl: my_wsdl, proxy: "http://proxy:secret-key@proxy-0-0-0-0.proximo.io")
但是当我提出请求时:
client.operations
我收到代理错误:
Wasabi::Resolver::HTTPError: Error: 407 for url http://mywsdl
from /Users/ahamon/.gem/ruby/2.3.0/gems/wasabi3.5.0/lib/wasabi/resolver.rb:45:in `load_from_remote'
from /Users/ahamon/.gem/ruby/2.3.0/gems/wasabi3.5.0/lib/wasabi/resolver.rb:33:in `resolve'
from /Users/ahamon/.gem/ruby/2.3.0/gems/wasabi3.5.0/lib/wasabi/document.rb:142:in `xml'
from /Users/ahamon/.gem/ruby/2.3.0/gems/wasabi-3.5.0/lib/wasabi/document.rb:160:in `parse'
from /Users/ahamon/.gem/ruby/2.3.0/gems/wasabi-3.5.0/lib/wasabi/document.rb:147:in `parser'
from /Users/ahamon/.gem/ruby/2.3.0/gems/wasabi-3.5.0/lib/wasabi/document.rb:64:in `soap_actions'
from /Users/ahamon/.gem/ruby/2.3.0/gems/savon-2.11.1/lib/savon/client.rb:28:in `operations'
from (irb):7
from /Users/ahamon/.gem/ruby/2.3.0/gems/railties-4.2.4/lib/rails/commands/console.rb:110:in `start'
from /Users/ahamon/.gem/ruby/2.3.0/gems/railties-4.2.4/lib/rails/commands/console.rb:9:in `start'
from /Users/ahamon/.gem/ruby/2.3.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:68:in `console'
from /Users/ahamon/.gem/ruby/2.3.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Users/ahamon/.gem/ruby/2.3.0/gems/railties-4.2.4/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
不过,如果没有代理选项,一切都可以正常工作。