how to set savon default timeout value

*爱你&永不变心* 提交于 2019-12-05 02:08:10

Savon uses the gem HTTPI as interface to the transport layer. Therefore you need to change the timeout for the http calls.

here an example (Savon 1.x)

jira = Savon::Client.new do
    wsdl.document = 'http://jira.my-domain.com/rpc/soap/jirasoapservice-v2?wsdl'
end

jira.http.read_timeout = 300

EDIT: the syntax has changed for Savon 2.x

jira = Savon.client(
    wsdl: 'http://jira.my-domain.com/rpc/soap/jirasoapservice-v2?wsdl',
    open_timeout: 300,
    read_timeout: 300,
    ssl_verify_mode: :none)
p jira.operations

In Savon 3, the operation is as follows:

client = Savon.new(wsdl_url)
client.http.send_timeout    = 300
client.http.receive_timeout = 300

In Savon 3, you can't pass these in as options to the constructor, but you can supply a custom http adapter (to replace the default Savon::HTTPClient) as follows:

client = Savon.new(wsdl_url, MyAdapter.new)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!