1

I'm using savon to communicate with a soap web service. It all works well, and I now need to get the ruby code into production where we have to go through a proxy server. This proxy server requires authentication.

So my question is, how can I go ahead to specify proxy server authentication details with savon?

Some further info:

I've figured out that you can specify a proxy server as such:

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

Looking through the code for savon, I found that the http variable in the client block refers to the following:

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

Unfortunately, going through the code for HTTPI::Request, I couldn't see a way to specify authentication for the proxy itself. Here's the code for the httpi request: https://github.com/rubiii/httpi/blob/master/lib/httpi/request.rb

Just to be clear: I'm not trying to do HTTP authentication, I'm attempting to perform proxy authentication.

When specifying the proxy server, I get the following error, because I can't find a way to specify the proxy authentication credentials:

407 "Proxy Authentication Required"

Thanks in advance for any help.

hendrikswan
  • 2,263
  • 1
  • 20
  • 25

2 Answers2

3

Try this: http.proxy = "http://username:password@host:port"

Alex De Simone
  • 572
  • 1
  • 4
  • 8
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