Class: Savon::Request
Overview
Savon::Request
Handles both WSDL and SOAP HTTP requests.
Constant Summary collapse
- ContentType =
Content-Types by SOAP version.
{ 1 => "text/xml", 2 => "application/soap+xml" }
Class Attribute Summary collapse
-
.log ⇒ Object
writeonly
Sets whether to log HTTP requests.
-
.log_level ⇒ Object
Accessor for the default log level.
-
.logger ⇒ Object
Accessor for the default logger.
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
readonly
Returns the endpoint URI.
Class Method Summary collapse
-
.log? ⇒ Boolean
Returns whether to log HTTP requests.
Instance Method Summary collapse
-
#initialize(endpoint) ⇒ Request
constructor
Expects an endpoint String.
-
#soap(soap) ⇒ Object
Executes a SOAP request using a given Savon::SOAP instance and returns the Net::HTTPResponse.
-
#wsdl ⇒ Object
Retrieves WSDL document and returns the Net::HTTPResponse.
Constructor Details
#initialize(endpoint) ⇒ Request
Expects an endpoint String. Raises an exception in case the given endpoint
does not seem to be valid.
38 39 40 41 42 43 |
# File 'lib/savon/request.rb', line 38 def initialize(endpoint) raise ArgumentError, "Invalid endpoint: #{endpoint}" unless /^(http|https):\/\// === endpoint @endpoint = URI endpoint end |
Class Attribute Details
.log=(value) ⇒ Object (writeonly)
Sets whether to log HTTP requests.
22 23 24 |
# File 'lib/savon/request.rb', line 22 def log=(value) @log = value end |
.log_level ⇒ Object
Accessor for the default log level.
33 34 35 |
# File 'lib/savon/request.rb', line 33 def log_level @log_level end |
.logger ⇒ Object
Accessor for the default logger.
30 31 32 |
# File 'lib/savon/request.rb', line 30 def logger @logger end |
Instance Attribute Details
#endpoint ⇒ Object (readonly)
Returns the endpoint URI.
46 47 48 |
# File 'lib/savon/request.rb', line 46 def endpoint @endpoint end |
Class Method Details
.log? ⇒ Boolean
Returns whether to log HTTP requests.
25 26 27 |
# File 'lib/savon/request.rb', line 25 def log? @log end |
Instance Method Details
#soap(soap) ⇒ Object
Executes a SOAP request using a given Savon::SOAP instance and returns the Net::HTTPResponse.
56 57 58 59 60 61 62 63 |
# File 'lib/savon/request.rb', line 56 def soap(soap) @soap = soap log_request @response = http.request_post @endpoint.path, @soap.to_xml, http_header log_response @response end |
#wsdl ⇒ Object
Retrieves WSDL document and returns the Net::HTTPResponse.
49 50 51 52 |
# File 'lib/savon/request.rb', line 49 def wsdl log "Retrieving WSDL from: #{@endpoint}" http.get @endpoint.to_s end |