如何在soap4r中为soap调用设置http标头?

时间:2011-02-07 10:17:40

标签: ruby web-services soap soap4r

如何在soap4r中为soap调用设置http标头?

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

如何设置http标头“vmware_soap_session”来调用@drv中的调用?

1 个答案:

答案 0 :(得分:1)

headerSOAP::NetHttpClient.get_content方法提供SOAP::NetHttpClient.post哈希参数:

这是第一个有助于'摒弃它的来源:

# 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

尝试将header哈希设置为{"vmware_soap_session" => true}或您应该用作值的任何内容。