How to I set a http header for a soap call in soap4r?

452 views Asked by At

How to I set a http header for a soap call in soap4r ?

@drv = SOAP::RPC::Driver.new('x', 'y')

How do I set a http header "vmware_soap_session" to call the calls that are going out of @drv ?

1

There are 1 answers

0
the Tin Man On BEST ANSWER

There's a header hash parameter available with the SOAP::NetHttpClient.get_content and SOAP::NetHttpClient.post methods:

Here's the source for the first that helps 'splain it:

# File 'lib/soap/netHttpClient.rb', line 95

def get_content(url, header = {})
  if str = @test_loopback_response.shift
    return str
  end
  unless url.is_a?(URI)
    url = URI.parse(url)
  end
  extra = header.dup
  extra['User-Agent'] = @agent if @agent
  res = start(url) { |http|
    http.get(url.request_uri, extra)
  }
  res.body
end

Try setting the header hash to {"vmware_soap_session" => true} or whatever you're supposed to use as the value.