Skip to content

Instantly share code, notes, and snippets.

@jcuffe
Created August 3, 2012 23:05
Show Gist options
  • Select an option

  • Save jcuffe/3252439 to your computer and use it in GitHub Desktop.

Select an option

Save jcuffe/3252439 to your computer and use it in GitHub Desktop.
def build_response(soap_request, retries = 0)
request_uri = URI.parse soap_request.url
request_http = Patron::Session.new
request_http.timeout = 10
request_http.base_url = request_uri.host
begin
raw_response = request_http.post(request_uri.path, soap_request.content, soap_request.headers).body
rescue Patron::TimeoutError
Rails.logger.debug "Patron timed out while attempting to connect to the Web Service"
if retries = 5 then throw
build_response soap_request, retries + 1
end
response = @soap_client.response soap_request, raw_response
parsed_response = JSON.parse response.body_hash['GetMonthlyReportDataResult']
parsed_response['resultSet']
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment