如何在soap4r中为soap调用设置http头? [英] How to I set a http header for a soap call in soap4r?
本文介绍了如何在soap4r中为soap调用设置http头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在soap4r 中为soap 调用设置http 标头?
How to I set a http header for a soap call in soap4r ?
@drv = SOAP::RPC::Driver.new('x', 'y')
如何设置 http 标头vmware_soap_session"来调用从 @drv 发出的调用?
How do I set a http header "vmware_soap_session" to call the calls that are going out of @drv ?
推荐答案
SOAP::NetHttpClient.get_content
和 SOAP 提供了一个
方法:header
哈希参数::NetHttpClient.post
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
尝试将 header
哈希设置为 {"vmware_soap_session" =>true}
或任何你应该用作值的东西.
Try setting the header
hash to {"vmware_soap_session" => true}
or whatever you're supposed to use as the value.
这篇关于如何在soap4r中为soap调用设置http头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文