class Savon::SOAP::Request
Savon::SOAP::Request¶ ↑
Executes SOAP requests.
Constants
- ContentType
Content-Types by SOAP version.
Attributes
request[RW]
Accessor for the HTTPI::Request
.
Public Class Methods
execute(request, soap)
click to toggle source
Expects an HTTPI::Request
and a Savon::SOAP::XML
object to execute a SOAP request and returns the
response.
# File lib/savon/soap/request.rb, line 17 def self.execute(request, soap) new(request, soap).response end
new(request, soap)
click to toggle source
Expects an HTTPI::Request
and a Savon::SOAP::XML
object.
# File lib/savon/soap/request.rb, line 22 def initialize(request, soap) self.request = setup(request, soap) end
Public Instance Methods
response()
click to toggle source
Executes the request and returns the response.
# File lib/savon/soap/request.rb, line 30 def response @response ||= with_logging { HTTPI.post request } end
Private Instance Methods
log_request(url, headers, body)
click to toggle source
Logs the SOAP request url
,
headers
and body
.
# File lib/savon/soap/request.rb, line 53 def log_request(url, headers, body) Savon.log "SOAP request: #{url}" Savon.log headers.map { |key, value| "#{key}: #{value}" }.join(", ") Savon.log body end
log_response(code, body)
click to toggle source
Logs the SOAP response code
and
body
.
# File lib/savon/soap/request.rb, line 60 def log_response(code, body) Savon.log "SOAP response (status #{code}):" Savon.log body end
setup(request, soap)
click to toggle source
Sets up the request
using a given soap
object.
# File lib/savon/soap/request.rb, line 37 def setup(request, soap) request.url = soap.endpoint request.headers["Content-Type"] ||= ContentType[soap.version] request.body = soap.to_xml request end
with_logging() { || ... }
click to toggle source
Logs the HTTP request, yields to a given
block
and returns a Savon::SOAP::Response
.
# File lib/savon/soap/request.rb, line 45 def with_logging log_request request.url, request.headers, request.body response = yield log_response response.code, response.body SOAP::Response.new response end