Class: ServiceProxy::Base
- Inherits:
-
Object
- Object
- ServiceProxy::Base
- Defined in:
- lib/service_proxy/base.rb
Constant Summary collapse
- VERSION =
'0.1.4'
Instance Attribute Summary collapse
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
-
#http ⇒ Object
Returns the value of attribute http.
-
#service_http ⇒ Object
writeonly
Sets the attribute service_http.
-
#service_methods ⇒ Object
Returns the value of attribute service_methods.
-
#service_ports ⇒ Object
Returns the value of attribute service_ports.
-
#service_uri ⇒ Object
writeonly
Sets the attribute service_uri.
-
#soap_actions ⇒ Object
Returns the value of attribute soap_actions.
-
#target_namespace ⇒ Object
Returns the value of attribute target_namespace.
-
#uri ⇒ Object
Returns the value of attribute uri.
-
#wsdl ⇒ Object
Returns the value of attribute wsdl.
Instance Method Summary collapse
- #call_service(options) ⇒ Object
-
#initialize(endpoint) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(endpoint) ⇒ Base
Returns a new instance of Base.
18 19 20 21 |
# File 'lib/service_proxy/base.rb', line 18 def initialize(endpoint) self.endpoint = endpoint self.setup end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object (private)
134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/service_proxy/base.rb', line 134 def method_missing(method, *args) method_name = method.to_s case method_name when /_uri$/ sp_name = method_name.gsub(/_uri$/, '') super unless self.service_ports.has_key?(sp_name) URI.parse(self.service_ports[sp_name]) else = args.pop || {} super unless self.service_methods.include?(method_name) call_service(.update(:method => method_name)) end end |
Instance Attribute Details
#debug ⇒ Object
Returns the value of attribute debug.
16 17 18 |
# File 'lib/service_proxy/base.rb', line 16 def debug @debug end |
#endpoint ⇒ Object
Returns the value of attribute endpoint.
16 17 18 |
# File 'lib/service_proxy/base.rb', line 16 def endpoint @endpoint end |
#http ⇒ Object
Returns the value of attribute http.
16 17 18 |
# File 'lib/service_proxy/base.rb', line 16 def http @http end |
#service_http=(value) ⇒ Object
Sets the attribute service_http
16 17 18 |
# File 'lib/service_proxy/base.rb', line 16 def service_http=(value) @service_http = value end |
#service_methods ⇒ Object
Returns the value of attribute service_methods.
16 17 18 |
# File 'lib/service_proxy/base.rb', line 16 def service_methods @service_methods end |
#service_ports ⇒ Object
Returns the value of attribute service_ports.
16 17 18 |
# File 'lib/service_proxy/base.rb', line 16 def service_ports @service_ports end |
#service_uri=(value) ⇒ Object
Sets the attribute service_uri
16 17 18 |
# File 'lib/service_proxy/base.rb', line 16 def service_uri=(value) @service_uri = value end |
#soap_actions ⇒ Object
Returns the value of attribute soap_actions.
16 17 18 |
# File 'lib/service_proxy/base.rb', line 16 def soap_actions @soap_actions end |
#target_namespace ⇒ Object
Returns the value of attribute target_namespace.
16 17 18 |
# File 'lib/service_proxy/base.rb', line 16 def target_namespace @target_namespace end |
#uri ⇒ Object
Returns the value of attribute uri.
16 17 18 |
# File 'lib/service_proxy/base.rb', line 16 def uri @uri end |
#wsdl ⇒ Object
Returns the value of attribute wsdl.
16 17 18 |
# File 'lib/service_proxy/base.rb', line 16 def wsdl @wsdl end |
Instance Method Details
#call_service(options) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/service_proxy/base.rb', line 23 def call_service() method = [:method] headers = { 'content-type' => 'text/xml; charset=utf-8', 'SOAPAction' => self.soap_actions[method] } body = build_request(method, ) response = self.service_http.request_post(self.service_uri.path, body, headers) parse_response(method, response) end |