Module: Rmobio::WebServices::Wsdl

Defined in:
lib/rmobio/webservices.rb

Class Method Summary collapse

Class Method Details

.include(service, silent = false, param_wsdl = nil) ⇒ Object

This helps in intializing the WSDL based services one at a time. It loads the service using the appropriate WSDL file, and retries a default of 5 times if the service cannot be launched before failing.

:service is the service to be instantiated, for example ‘registration’

it should be associated with an equivalent WSDL file and constant like
REGISTRATION_WSDL.

:silent, default = false; This either throws an error if the service cannot load or allows the service to silently fail if the service cannot be instantiated correctly.

usage Rmobio::Webservices::Wsdl::include(‘registration’)

Rmobio::Webservices::Wsdl::include(‘messaging’, true) # this will fail silently if the service cannot be instantiated



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/rmobio/webservices.rb', line 43

def self.include(service, silent = false, param_wsdl=nil)
  begin
    require File.dirname(__FILE__) + '/webservices/soap/drivers'
    require File.dirname(__FILE__) + '/webservices/soap/' + service.downcase
    
    # added because this error was being observed:
    # /opt/local/lib/ruby/1.8/soap/wsdlDriver.rb:62:in `find_port':NoMethodError: undefined method `services' for #<WSDL::XMLSchema::Schema:0x1a41b80>
    # unsure what it does, but this retry sequence seems to load things properly
    tries = 0
    begin
      Module.const_get(service.downcase.capitalize).wsdl= param_wsdl
    rescue NoMethodError
      tries += 1
      p tries
      retry unless tries > 5 
    end
    # end retry
    
  rescue LoadError # no file to load
    raise $! unless silent
    return false
  rescue NameError # no constant
    raise $! unless silent
    return false
  end
end