How to write SOAP Authentication header with Ruby Savon

点点圈 提交于 2019-12-04 12:53:36

You need to include the authentification credentials in the SOAP header of your message. Savon offers the :soap_header symbol for it.

Your example could look like this:

require 'savon'
require 'securerandom'

realm = Base64.strict_encode64("ExampleUsername:ExamplePassword")
client = Savon.client(
    wsdl: "https://api.five9.com/wsadmin/v2/AdminWebService?wsdl",
    soap_header: { 'Authorization:' => "Basic #{realm}"},
    log: true,
    log_level: debug,
    pretty_print_xml: true
)

I couldn't test it this example because I lack the user credentials, but it passed "ruby -c".

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