Class: Savon::Client

Inherits:
Object show all
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.

Constant Summary collapse

@@wsdl =

Global setting of whether to use Savon::WSDL.

true

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(endpoint, options = {}) ⇒ Client

Expects a SOAP endpoint String. Also accepts an optional Hash of options for specifying a proxy server and SSL client authentication.



24
25
26
27
# File 'lib/savon/client.rb', line 24

def initialize(endpoint,options = {})
  @request = Request.new endpoint, options
  @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)

Dispatches requests to SOAP actions matching a given method name.



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

def method_missing(method, *args, &block) #:doc:
  super if wsdl? && !@wsdl.respond_to?(method)

  setup operation_from(method), &block
  dispatch method
end

Instance Attribute Details

#requestObject (readonly)

Returns the Savon::Request.



33
34
35
# File 'lib/savon/client.rb', line 33

def request
  @request
end

#wsdlObject

Accessor for Savon::WSDL.



30
31
32
# File 'lib/savon/client.rb', line 30

def wsdl
  @wsdl
end

Class Method Details

.wsdl=(wsdl) ⇒ Object

Sets the global setting of whether to use Savon::WSDL.



13
14
15
# File 'lib/savon/client.rb', line 13

def self.wsdl=(wsdl)
  @@wsdl = wsdl
end

.wsdl?Boolean

Returns the global setting of whether to use Savon::WSDL.

Returns:

  • (Boolean)


18
19
20
# File 'lib/savon/client.rb', line 18

def self.wsdl?
  @@wsdl
end

Instance Method Details

#respond_to?(method) ⇒ Boolean

Returns true for available methods and SOAP actions.

Returns:

  • (Boolean)


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

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

#wsdl?Boolean

Returns whether to use Savon::WSDL.

Returns:

  • (Boolean)


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

def wsdl?
  self.class.wsdl? && @wsdl
end