lib/rforce/binding.rb in rforce-0.3 vs lib/rforce/binding.rb in rforce-0.4

- old
+ new

@@ -1,5 +1,12 @@ +require 'net/https' +require 'uri' +require 'zlib' +require 'stringio' +require 'builder' + + module RForce # Implements the connection to the SalesForce server. class Binding include RForce @@ -82,14 +89,17 @@ # Call a method on the remote server. Arguments can be # a hash or (if order is important) an array of alternating # keys and values. def call_remote(method, args) + + urn, soap_url = block_given? ? yield : ["urn:partner.soap.sforce.com", @url.path] + # Create XML text from the arguments. expanded = '' @builder = Builder::XmlMarkup.new(:target => expanded) - expand(@builder, {method => args}, 'urn:partner.soap.sforce.com') + expand(@builder, {method => args}, urn) extra_headers = "" extra_headers << (AssignmentRuleHeaderUsingRuleId % assignment_rule_id) if assignment_rule_id extra_headers << AssignmentRuleHeaderUsingDefaultRule if use_default_rule extra_headers << MruHeader if update_mru @@ -126,11 +136,11 @@ headers['Accept-Encoding'] = 'gzip' headers['Content-Encoding'] = 'gzip' end # Send the request to the server and read the response. - response = @server.post2(@url.path, request.lstrip, headers) + response = @server.post2(soap_url, request.lstrip, headers) # decode if we have encoding content = decode(response) # Check to see if INVALID_SESSION_ID was raised and try to relogin in @@ -140,10 +150,10 @@ # repackage and rencode request with the new session id request = (Envelope % [@session_id, @batch_size, extra_headers, expanded]) request = encode(request) # Send the request to the server and read the response. - response = @server.post2(@url.path, request.lstrip, headers) + response = @server.post2(soap_url, request.lstrip, headers) content = decode(response) end SoapResponse.new(content).parse