Welcome to Working With Rails

 

Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
not able to set proxy (proxy url, port, username and password) for accessing webservice
3 Posts
not able to set proxy (proxy url, port, username and password) for accessing webservice

Hello,

I am facing problem during accessing web service beyond proxy. I am successfully able access the same web service without proxy. Please suggest how to set proxy object while calling the web service.  

here is code that i am using for calling soap based web service.

factory = SOAP::WSDLDriverFactory.new() soap = factory.create_rpc_driver

For time being I overwrite net/http method in my application itself. I write following snippet of code in my environment.rb file. It solved my problem.
require 'net/protocol'

module Net class HTTP < Protocol

def HTTP.new(address, port = nil, p_addr = "", p_port = , p_user = "", p_pass = "")
    h = Proxy(p_addr, p_port, p_user, p_pass).newobj(address, port)
    h.instance_eval {
      @newimpl = ::Net::HTTP.version_1_2?
  }
  h
end

end end

you can also write this code in lib file and require that file in to your code when required

can you try using environment variable to set proxy?

ENV['http_proxy'] = "http://mysekret.proxy,com"

factory = SOAP::WSDLDriverFactory.new() soap = factory.create_rpc_driver

3 Posts
Login to add your message