Created
November 28, 2008 19:41
-
-
Save alcabanillas-engh/30067 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Require the library for SOAP | |
require 'rubygems' | |
require 'configatron' | |
require 'soap/wsdlDriver' | |
require 'digest/md5' | |
require 'active_support' | |
#Build our credentials hash to be passed to the SOAP factory and converted to XML to pass to Sugar CRM | |
credentials = { "user_name" => $config["global_settings"]["username"], | |
"password" => Digest::MD5.hexdigest($config["global_settings"]["password"]) } | |
begin | |
#Connect to the Sugar CRM WSDL and build our methods in Ruby | |
ws_proxy = SOAP::WSDLDriverFactory.new($config["global_settings"]["wsdl_url"]).create_rpc_driver | |
ws_proxy.options['protocol.http.ssl_config.verify_mode'] = OpenSSL::SSL::VERIFY_NONE | |
#This may be toggled on to log XML requests/responses for debugging | |
if $config["global_settings"]["trace_xml_wire"] == true | |
ws_proxy.wiredump_file_base = "soap" | |
end | |
#Login to Sugar CRM | |
session = ws_proxy.login(credentials, nil) | |
rescue => err | |
puts err | |
abort | |
end | |
#Check to see we got logged in properly | |
if session.error.number.to_i != 0 | |
puts session.error.description + " (" + session.error.number + ")" | |
puts "Exiting" | |
abort | |
else | |
puts "Successfully logged in" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment