Class: Sylfy::Service::SOAPWSDL
- Inherits:
-
Object
- Object
- Sylfy::Service::SOAPWSDL
- Defined in:
- lib/sylfy/service/soapwsdl.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(wsdl, options = {}) ⇒ SOAPWSDL
constructor
Parameters: wsdl:: options::.
-
#list_methods ⇒ Object
List of methods defined by WSDL.
Constructor Details
#initialize(wsdl, options = {}) ⇒ SOAPWSDL
Parameters:
- wsdl
- options
33 34 35 36 37 38 39 |
# File 'lib/sylfy/service/soapwsdl.rb', line 33 def initialize(wsdl, = {}) @options = @options[:wsdl] = wsdl @options[:log] = false if !@options.has_key?(:log) @options[:pretty_print_xml] = true if @options.has_key?(:log_level) && @options[:log_level] == :debug @client = Savon.client(@options) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object (private)
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/sylfy/service/soapwsdl.rb', line 46 def method_missing(m, *args, &block) response = @client.call(m, message: args[0]) if @options[:log_level] == :debug puts response.body puts response.success? # => false puts response.soap_fault? # => true puts response.http_error? end if response.body[:"#{m}_response"].has_key?(:"#{m}_return") result = response.body[:"#{m}_response"][:"#{m}_return"] else result = response.body[:"#{m}_response"][:return] end if result.class == Hash result.delete_if {|k, v| k.to_s =~ /^@/} return result.empty? ? "" : result else return result end end |
Instance Method Details
#list_methods ⇒ Object
List of methods defined by WSDL
42 43 44 |
# File 'lib/sylfy/service/soapwsdl.rb', line 42 def list_methods @client.operations end |