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.



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

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.



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

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.



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

def error_handling
  @error_handling
end

.response_processObject

Accessor for the default response block.



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

def response_process
  @response_process
end

Instance Attribute Details

#responseObject (readonly)

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



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

def response
  @response
end

#wsdlObject (readonly)

Returns the Savon::WSDL.



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

def wsdl
  @wsdl
end

Instance Method Details

#respond_to?(method) ⇒ Boolean

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

Returns:

  • (Boolean)


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

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