Parent

Namespace

Included Modules

Files

Class Index [+]

Quicksearch

SOAP::RPC::Proxy

Attributes

soapaction[RW]
mandatorycharset[RW]
allow_unqualified_element[RW]
default_encodingstyle[RW]
generate_explicit_type[RW]
use_default_namespace[RW]
return_response_as_xml[RW]
headerhandler[R]
filterchain[R]
streamhandler[R]
mapping_registry[RW]
literal_mapping_registry[RW]
operation[R]

Public Class Methods

new(endpoint_url, soapaction, options) click to toggle source
    # File lib/soap/rpc/proxy.rb, line 46
46:   def initialize(endpoint_url, soapaction, options)
47:     @endpoint_url = endpoint_url
48:     @soapaction = soapaction
49:     @options = options
50:     @protocol_option = options["protocol"] ||= ::SOAP::Property.new
51:     initialize_streamhandler(@protocol_option)
52:     @operation = {}
53:     @operation_by_qname = {}
54:     @operation_by_soapaction = {}
55:     @mandatorycharset = nil
56:     # TODO: set to false by default or drop thie option in 1.6.0
57:     @allow_unqualified_element = true
58:     @default_encodingstyle = nil
59:     @generate_explicit_type = true
60:     @use_default_namespace = false
61:     @return_response_as_xml = false
62:     @headerhandler = Header::HandlerSet.new
63:     @filterchain = Filter::FilterChain.new
64:     @mapping_registry = nil
65:     @literal_mapping_registry = ::SOAP::Mapping::LiteralRegistry.new
66:   end

Public Instance Methods

add_document_method(soapaction, name, param_def, opt = {}) click to toggle source
add_document_operation(soapaction, name, param_def, opt = {}) click to toggle source
     # File lib/soap/rpc/proxy.rb, line 100
100:   def add_document_operation(soapaction, name, param_def, opt = {})
101:     ensure_styleuse_option(opt, :document, :literal)
102:     op = Operation.new(soapaction, param_def, opt)
103:     assign_operation(name, nil, soapaction, op)
104:   end
Also aliased as: add_document_method
add_method(qname, soapaction, name, param_def, opt = {}) click to toggle source

add_method is for shortcut of typical rpc/encoded method definition.

Alias for: add_rpc_operation
add_rpc_method(qname, soapaction, name, param_def, opt = {}) click to toggle source
Alias for: add_rpc_operation
add_rpc_operation(qname, soapaction, name, param_def, opt = {}) click to toggle source
    # File lib/soap/rpc/proxy.rb, line 93
93:   def add_rpc_operation(qname, soapaction, name, param_def, opt = {})
94:     ensure_styleuse_option(opt, :rpc, :encoded)
95:     opt[:request_qname] = qname
96:     op = Operation.new(soapaction, param_def, opt)
97:     assign_operation(name, qname, soapaction, op)
98:   end
Also aliased as: add_method, add_rpc_method
call(name, *params) click to toggle source
     # File lib/soap/rpc/proxy.rb, line 121
121:   def call(name, *params)
122:     # name must be used only for lookup
123:     op_info = lookup_operation(name)
124:     mapping_opt = create_mapping_opt
125:     req_header = create_request_header
126:     req_body = SOAPBody.new(
127:       op_info.request_body(params, @mapping_registry,
128:         @literal_mapping_registry, mapping_opt)
129:     )
130:     reqopt = create_encoding_opt(
131:       :soapaction => op_info.soapaction || @soapaction,
132:       :envelopenamespace => @options["soap.envelope.requestnamespace"],
133:       :default_encodingstyle =>
134:         @default_encodingstyle || op_info.request_default_encodingstyle,
135:       :use_default_namespace =>
136:         op_info.use_default_namespace || @use_default_namespace
137:     )
138:     resopt = create_encoding_opt(
139:       :envelopenamespace => @options["soap.envelope.responsenamespace"],
140:       :default_encodingstyle =>
141:         @default_encodingstyle || op_info.response_default_encodingstyle
142:     )
143:     env = route(req_header, req_body, reqopt, resopt)
144:     if op_info.response_use.nil?
145:       return nil
146:     end
147:     raise EmptyResponseError unless env
148:     receive_headers(env.header)
149:     begin
150:       check_fault(env.body)
151:     rescue ::SOAP::FaultError => e
152:       op_info.raise_fault(e, @mapping_registry, @literal_mapping_registry)
153:     end
154:     if @return_response_as_xml
155:       resopt[:response_as_xml]
156:     else
157:       op_info.response_obj(env.body, @mapping_registry,
158:         @literal_mapping_registry, mapping_opt)
159:     end
160:   end
check_fault(body) click to toggle source
     # File lib/soap/rpc/proxy.rb, line 187
187:   def check_fault(body)
188:     if body.fault
189:       raise SOAP::FaultError.new(body.fault)
190:     end
191:   end
endpoint_url() click to toggle source
    # File lib/soap/rpc/proxy.rb, line 72
72:   def endpoint_url
73:     @endpoint_url
74:   end
endpoint_url=(endpoint_url) click to toggle source
    # File lib/soap/rpc/proxy.rb, line 76
76:   def endpoint_url=(endpoint_url)
77:     @endpoint_url = endpoint_url
78:     reset_stream
79:   end
inspect() click to toggle source
    # File lib/soap/rpc/proxy.rb, line 68
68:   def inspect
69:     "#<#{self.class}:#{@endpoint_url}>"
70:   end
invoke(req_header, req_body, opt = nil) click to toggle source
     # File lib/soap/rpc/proxy.rb, line 111
111:   def invoke(req_header, req_body, opt = nil)
112:     opt ||= create_encoding_opt
113:     env = route(req_header, req_body, opt, opt)
114:     if @return_response_as_xml
115:       opt[:response_as_xml]
116:     else
117:       env
118:     end
119:   end
reset_stream() click to toggle source
    # File lib/soap/rpc/proxy.rb, line 81
81:   def reset_stream
82:     @streamhandler.reset(@endpoint_url)
83:   end
route(req_header, req_body, reqopt, resopt) click to toggle source
     # File lib/soap/rpc/proxy.rb, line 162
162:   def route(req_header, req_body, reqopt, resopt)
163:     req_env = ::SOAP::SOAPEnvelope.new(req_header, req_body)
164:     unless reqopt[:envelopenamespace].nil?
165:       set_envelopenamespace(req_env, reqopt[:envelopenamespace])
166:     end
167:     reqopt[:external_content] = nil
168:     conn_data = marshal(req_env, reqopt)
169:     if ext = reqopt[:external_content]
170:       mime = MIMEMessage.new
171:       ext.each do |k, v|
172:         mime.add_attachment(v.data)
173:       end
174:       mime.add_part(conn_data.send_string + "\r\n")
175:       mime.close
176:       conn_data.send_string = mime.content_str
177:       conn_data.send_contenttype = mime.headers['content-type'].str
178:     end
179:     conn_data = @streamhandler.send(@endpoint_url, conn_data,
180:       reqopt[:soapaction])
181:     if conn_data.receive_string.empty?
182:       return nil
183:     end
184:     unmarshal(conn_data, resopt)
185:   end
set_wiredump_file_base(wiredump_file_base) click to toggle source
    # File lib/soap/rpc/proxy.rb, line 85
85:   def set_wiredump_file_base(wiredump_file_base)
86:     @streamhandler.wiredump_file_base = wiredump_file_base
87:   end
test_loopback_response() click to toggle source
    # File lib/soap/rpc/proxy.rb, line 89
89:   def test_loopback_response
90:     @streamhandler.test_loopback_response
91:   end

Private Instance Methods

assign_operation(name, qname, soapaction, op) click to toggle source
     # File lib/soap/rpc/proxy.rb, line 315
315:   def assign_operation(name, qname, soapaction, op)
316:     assigned = false
317:     if name and !name.empty?
318:       @operation[name] = op
319:       assigned = true
320:     end
321:     if qname
322:       @operation_by_qname[qname] = op
323:       assigned = true
324:     end
325:     if soapaction and !soapaction.empty?
326:       @operation_by_soapaction[soapaction] = op
327:       assigned = true
328:     end
329:     unless assigned
330:       raise MethodDefinitionError.new("cannot assign operation")
331:     end
332:   end
create_encoding_opt(hash = nil) click to toggle source
     # File lib/soap/rpc/proxy.rb, line 295
295:   def create_encoding_opt(hash = nil)
296:     opt = {}
297:     opt[:default_encodingstyle] = @default_encodingstyle
298:     opt[:allow_unqualified_element] = @allow_unqualified_element
299:     opt[:generate_explicit_type] = @generate_explicit_type
300:     opt[:no_indent] = @options["soap.envelope.no_indent"]
301:     opt[:use_numeric_character_reference] =
302:       @options["soap.envelope.use_numeric_character_reference"]
303:     opt.update(hash) if hash
304:     opt
305:   end
create_mapping_opt(hash = nil) click to toggle source
     # File lib/soap/rpc/proxy.rb, line 307
307:   def create_mapping_opt(hash = nil)
308:     opt = {
309:       :external_ces => @options["soap.mapping.external_ces"]
310:     }
311:     opt.update(hash) if hash
312:     opt
313:   end
create_request_header() click to toggle source
     # File lib/soap/rpc/proxy.rb, line 238
238:   def create_request_header
239:     header = ::SOAP::SOAPHeader.new
240:     items = @headerhandler.on_outbound(header)
241:     items.each do |item|
242:       header.add(item.elename.name, item)
243:     end
244:     header
245:   end
ensure_styleuse_option(opt, style, use) click to toggle source
     # File lib/soap/rpc/proxy.rb, line 195
195:   def ensure_styleuse_option(opt, style, use)
196:     if opt[:request_style] || opt[:response_style] || opt[:request_use] || opt[:response_use]
197:       # do not edit
198:     else
199:       opt[:request_style] ||= style
200:       opt[:response_style] ||= style
201:       opt[:request_use] ||= use
202:       opt[:response_use] ||= use
203:     end
204:   end
initialize_streamhandler(options) click to toggle source
     # File lib/soap/rpc/proxy.rb, line 206
206:   def initialize_streamhandler(options)
207:     value = options["streamhandler"]
208:     if value and !value.empty?
209:       factory = Property::Util.const_from_name(value)
210:     else
211:       factory = HTTPStreamHandler
212:     end
213:     @streamhandler = factory.create(options)
214:     options.add_hook("streamhandler") do |key, value|
215:       @streamhandler.reset
216:       if value.respond_to?(:create)
217:         factory = value
218:       elsif value and !value.to_str.empty?
219:         factory = Property::Util.const_from_name(value.to_str)
220:       else
221:         factory = HTTPStreamHandler
222:       end
223:       options.unlock(true)
224:       @streamhandler = factory.create(options)
225:     end
226:   end
lookup_operation(name_or_qname_or_soapaction) click to toggle source
     # File lib/soap/rpc/proxy.rb, line 334
334:   def lookup_operation(name_or_qname_or_soapaction)
335:     if op = @operation[name_or_qname_or_soapaction]
336:       return op
337:     end
338:     if op = @operation_by_qname[name_or_qname_or_soapaction]
339:       return op
340:     end
341:     if op = @operation_by_soapaction[name_or_qname_or_soapaction]
342:       return op
343:     end
344:     raise MethodDefinitionError.new(
345:       "operation: #{name_or_qname_or_soapaction} not supported")
346:   end
marshal(env, opt) click to toggle source
     # File lib/soap/rpc/proxy.rb, line 251
251:   def marshal(env, opt)
252:     @filterchain.each do |filter|
253:       env = filter.on_outbound(env, opt)
254:       break unless env
255:     end
256:     send_string = Processor.marshal(env, opt)
257:     StreamHandler::ConnectionData.new(send_string)
258:   end
receive_headers(header) click to toggle source
     # File lib/soap/rpc/proxy.rb, line 247
247:   def receive_headers(header)
248:     @headerhandler.on_inbound(header) if header
249:   end
set_envelopenamespace(env, namespace) click to toggle source
     # File lib/soap/rpc/proxy.rb, line 228
228:   def set_envelopenamespace(env, namespace)
229:     env.elename = XSD::QName.new(namespace, env.elename.name)
230:     if env.header
231:       env.header.elename = XSD::QName.new(namespace, env.header.elename.name)
232:     end
233:     if env.body
234:       env.body.elename = XSD::QName.new(namespace, env.body.elename.name)
235:     end
236:   end
unmarshal(conn_data, opt) click to toggle source
     # File lib/soap/rpc/proxy.rb, line 260
260:   def unmarshal(conn_data, opt)
261:     contenttype = conn_data.receive_contenttype
262:     xml = nil
263:     if /#{MIMEMessage::MultipartContentType}/ =~ contenttype
264:       opt[:external_content] = {}
265:       mime = MIMEMessage.parse("Content-Type: " + contenttype,
266:         conn_data.receive_string)
267:       mime.parts.each do |part|
268:         value = Attachment.new(part.content)
269:         value.contentid = part.contentid
270:         obj = SOAPAttachment.new(value)
271:         opt[:external_content][value.contentid] = obj if value.contentid
272:       end
273:       opt[:charset] = @mandatorycharset ||
274:         StreamHandler.parse_media_type(mime.root.headers['content-type'].str)
275:       xml = mime.root.content
276:     else
277:       opt[:charset] = @mandatorycharset ||
278:         ::SOAP::StreamHandler.parse_media_type(contenttype)
279:       xml = conn_data.receive_string
280:     end
281:     @filterchain.reverse_each do |filter|
282:       xml = filter.on_inbound(xml, opt)
283:       break unless xml
284:     end
285:     env = Processor.unmarshal(xml, opt)
286:     if @return_response_as_xml
287:       opt[:response_as_xml] = xml
288:     end
289:     unless env.is_a?(::SOAP::SOAPEnvelope)
290:       raise ResponseFormatError.new("response is not a SOAP envelope: #{env}")
291:     end
292:     env
293:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.