Skip to content

Instantly share code, notes, and snippets.

@rubiii
Created June 6, 2010 20:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rubiii/427849 to your computer and use it in GitHub Desktop.
Save rubiii/427849 to your computer and use it in GitHub Desktop.
# rubygems.org/gems/savon by examples
# overview of examples at: http://gist.github.com/gists/427837
require "savon"
# HTTP basic authentication
client = Savon::Client.new do
wsdl.location = "http://users.example.com?wsdl"
request.basic_auth "username", "password"
end
# NTLM authentication
client = Savon::Client.new do
wsdl.location = "http://users.example.com?wsdl"
request.ntlm_auth "username", "password"
end
# WSSE authentication
client = Savon::Client.new do
wsdl.location = "http://users.example.com?wsdl"
wsse.credentials "username", "password"
end
# WSSE digest authentication
client = Savon::Client.new do
wsdl.location = "http://users.example.com?wsdl"
wsse.credentials "username", "password"
wsse.digest = true
end
# SSL client authentication
client = Savon::Client.new do
wsdl.location = "http://users.example.com?wsdl"
request.http.ssl_client_auth(
:cert => OpenSSL::X509::Certificate.new(File.read("client_cert.pem")),
:key => OpenSSL::PKey::RSA.new(File.read("client_key.pem"), "password if one exists"),
:ca_file => "cacert.pem",
:verify_mode => OpenSSL::SSL::VERIFY_PEER
)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment