Created
August 3, 2012 23:05
-
-
Save jcuffe/3252439 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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