SavonForce is an extremely simple wrapper using Savon to connect to the salesforce SOAP API.
As it’s using Savon, SavonForce needs to access the salesforce WSDL file over HTTP. Salesforce doesn’t have a publicly available link to the WSDL file since it’s generated per setup. You’ll need to generate your WSDL file (enterprise or partner) and place it somewhere you can access. Somewhere secure if you care about your data schema’s privacy. This requirement is fixed in Savon 0.8, which is yet to be released.
I solve this by placing my WSDL file on my machine, then serving it with the simple python: python -m SimpleHTTPServer ${1:-8080};. That line serves the current directory over http on port 8080.
SavonForce doesn’t know, or care, anything about the salesforce API up front. It’s purely a wrapper to the functions and data defined by the WSDL file.
SavonForce’s interface intentionally mirrors that of rforce.
This library is purely a proof of concept and has not (and should not) be used in a production environment.
require ‘mysalesforce’
- localhost:8080 is a directory served with:
- python -m SimpleHTTPServer ${1:-8080};
binding = SavonForce::Binding.new “http://localhost:8080/partner-wsdl.jsp.xml”
userID = ‘salesforce_user’
password = ‘password’
securityToken = ‘generated by salesforce’
binding.login userID, (password + securityToken)
- a simple search
result = binding.search(
{ :searchString => “FIND {Account Name} IN name FIELDS” \
“RETURNING account(id, name, phone) LIMIT 1” })
result_data = result[:search_records][:record]
- creating an account
response = binding.create :sObject => { :type => ‘Account’,
:name => ‘SavonForce Account’ }- response should be something like:
{:id=>"(salesforce generated ID)", :success=>true}
- Savon
- A SalesForce Enterprise or Developer account
- Place savonforce.rb in your load path.