Class: Handsoap::Service
- Inherits:
-
Object
show all
- Defined in:
- lib/handsoap/service.rb
Constant Summary
collapse
- @@logger =
nil
- @@instance =
{}
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
155
156
157
158
159
160
161
162
|
# File 'lib/handsoap/service.rb', line 155
def method_missing(method, *args)
action = self.class.get_mapping(method)
if action
invoke(action, *args)
else
super
end
end
|
Class Method Details
.endpoint(args = {}) ⇒ Object
111
112
113
114
|
# File 'lib/handsoap/service.rb', line 111
def self.endpoint(args = {})
@protocol_version = args[:version] || raise("Missing option :version")
@uri = args[:uri] || raise("Missing option :uri")
end
|
.envelope_namespace ⇒ Object
115
116
117
118
119
120
|
# File 'lib/handsoap/service.rb', line 115
def self.envelope_namespace
if SOAP_NAMESPACE[@protocol_version].nil?
raise "Unknown protocol version '#{@protocol_version.inspect}'"
end
SOAP_NAMESPACE[@protocol_version]
end
|
.fire_on_create_document(doc) ⇒ Object
133
134
135
136
137
|
# File 'lib/handsoap/service.rb', line 133
def self.fire_on_create_document(doc)
if @create_document_callback
@create_document_callback.call doc
end
end
|
.get_mapping(name) ⇒ Object
141
142
143
|
# File 'lib/handsoap/service.rb', line 141
def self.get_mapping(name)
@mapping[name] if @mapping
end
|
.instance ⇒ Object
145
146
147
|
# File 'lib/handsoap/service.rb', line 145
def self.instance
@@instance[self.to_s] ||= self.new
end
|
.logger=(io) ⇒ Object
108
109
110
|
# File 'lib/handsoap/service.rb', line 108
def self.logger=(io)
@@logger = io
end
|
.map_method(mapping) ⇒ Object
124
125
126
127
128
129
|
# File 'lib/handsoap/service.rb', line 124
def self.map_method(mapping)
if @mapping.nil?
@mapping = {}
end
@mapping.merge! mapping
end
|
.method_missing(method, *args) ⇒ Object
148
149
150
151
152
153
154
|
# File 'lib/handsoap/service.rb', line 148
def self.method_missing(method, *args)
if instance.respond_to?(method)
instance.__send__ method, *args
else
super
end
end
|
.on_create_document(&block) ⇒ Object
130
131
132
|
# File 'lib/handsoap/service.rb', line 130
def self.on_create_document(&block)
@create_document_callback = block
end
|
.request_content_type ⇒ Object
121
122
123
|
# File 'lib/handsoap/service.rb', line 121
def self.request_content_type
@protocol_version == 1 ? "text/xml" : "application/soap+xml"
end
|
.uri ⇒ Object
138
139
140
|
# File 'lib/handsoap/service.rb', line 138
def self.uri
@uri
end
|
Instance Method Details
#invoke(action, options = { :soap_action => :auto }, &block) ⇒ Object
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
# File 'lib/handsoap/service.rb', line 163
def invoke(action, options = { :soap_action => :auto }, &block)
if action
if options.kind_of? String
options = { :soap_action => options }
end
if options[:soap_action] == :auto
options[:soap_action] = action.gsub(/^.+:/, "")
elsif options[:soap_action] == :none
options[:soap_action] = nil
end
doc = make_envelope do |body|
body.add action
end
if block_given?
yield doc.find(action)
end
dispatch(doc, options[:soap_action])
end
end
|
#on_before_dispatch ⇒ Object
182
183
|
# File 'lib/handsoap/service.rb', line 182
def on_before_dispatch
end
|
#on_fault(fault) ⇒ Object
184
185
186
|
# File 'lib/handsoap/service.rb', line 184
def on_fault(fault)
raise fault
end
|