Class: Savon::Client

Inherits:
Object show all
Includes:
Validation
Defined in:
lib/savon/client.rb

Overview

Savon::Client

Heavy metal Ruby SOAP client library. Minimizes the overhead of working with SOAP services and XML.

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Validation

#validate!

Constructor Details

#initialize(endpoint) ⇒ Client

Expects a SOAP endpoint String.



45
46
47
48
# File 'lib/savon/client.rb', line 45

def initialize(endpoint)
  @request = Request.new endpoint
  @wsdl = WSDL.new @request
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (private)

Behaves as usual, but dispatches SOAP requests to SOAP actions matching the given method name.



66
67
68
69
70
71
72
73
# File 'lib/savon/client.rb', line 66

def method_missing(method, *args, &block) #:doc:
  soap_action = @wsdl.mapped_soap_actions[method]
  super unless soap_action

  soap_body, options = args[0] || {}, args[1] || {}
  validate_arguments! soap_body, options, block
  dispatch soap_action, soap_body, options, block
end

Class Attribute Details

.error_handlingObject

Accessor for the default error handling.



40
41
42
# File 'lib/savon/client.rb', line 40

def error_handling
  @error_handling
end

.response_processObject

Accessor for the default response block.



37
38
39
# File 'lib/savon/client.rb', line 37

def response_process
  @response_process
end

Instance Attribute Details

#responseObject (readonly)

Returns the Net::HTTPResponse of the last SOAP request.



54
55
56
# File 'lib/savon/client.rb', line 54

def response
  @response
end

#wsdlObject (readonly)

Returns the Savon::WSDL.



51
52
53
# File 'lib/savon/client.rb', line 51

def wsdl
  @wsdl
end

Instance Method Details

#respond_to?(method) ⇒ Boolean

Behaves as usual, but also returns true for available SOAP actions.

Returns:

  • (Boolean)


57
58
59
60
# File 'lib/savon/client.rb', line 57

def respond_to?(method)
  return true if @wsdl.soap_actions.include? method
  super
end