Class SOAP::RPC::Proxy::Operation
In: lib/soap/rpc/proxy.rb
Parent: Object

Methods

Attributes

attributeformdefault  [R] 
elementformdefault  [R] 
request_style  [R] 
request_use  [R] 
response_style  [R] 
response_use  [R] 
soapaction  [R] 

Public Class methods

[Source]

     # File lib/soap/rpc/proxy.rb, line 282
282:     def initialize(soapaction, param_def, opt)
283:       @soapaction = soapaction
284:       @request_style = opt[:request_style]
285:       @response_style = opt[:response_style]
286:       @request_use = opt[:request_use]
287:       @response_use = opt[:response_use]
288:       # set nil(unqualified) by default
289:       @elementformdefault = opt[:elementformdefault]
290:       @attributeformdefault = opt[:attributeformdefault]
291:       check_style(@request_style)
292:       check_style(@response_style)
293:       check_use(@request_use)
294:       check_use(@response_use)
295:       if @request_style == :rpc
296:         @rpc_request_qname = opt[:request_qname]
297:         if @rpc_request_qname.nil?
298:           raise MethodDefinitionError.new("rpc_request_qname must be given")
299:         end
300:         @rpc_method_factory =
301:           RPC::SOAPMethodRequest.new(@rpc_request_qname, param_def, @soapaction)
302:       else
303:         @doc_request_qnames = []
304:         @doc_request_qualified = []
305:         @doc_response_qnames = []
306:         @doc_response_qualified = []
307:         param_def.each do |inout, paramname, typeinfo, eleinfo|
308:           klass_not_used, nsdef, namedef = typeinfo
309:           qualified = eleinfo
310:           if namedef.nil?
311:             raise MethodDefinitionError.new("qname must be given")
312:           end
313:           case inout
314:           when SOAPMethod::IN
315:             @doc_request_qnames << XSD::QName.new(nsdef, namedef)
316:             @doc_request_qualified << qualified
317:           when SOAPMethod::OUT
318:             @doc_response_qnames << XSD::QName.new(nsdef, namedef)
319:             @doc_response_qualified << qualified
320:           else
321:             raise MethodDefinitionError.new(
322:               "illegal inout definition for document style: #{inout}")
323:           end
324:         end
325:       end
326:     end

Public Instance methods

[Source]

     # File lib/soap/rpc/proxy.rb, line 352
352:     def raise_fault(e, mapping_registry, literal_mapping_registry)
353:       if @response_style == :rpc
354:         Mapping.fault2exception(e, mapping_registry)
355:       else
356:         Mapping.fault2exception(e, literal_mapping_registry)
357:       end
358:     end

[Source]

     # File lib/soap/rpc/proxy.rb, line 336
336:     def request_body(values, mapping_registry, literal_mapping_registry, opt)
337:       if @request_style == :rpc
338:         request_rpc(values, mapping_registry, literal_mapping_registry, opt)
339:       else
340:         request_doc(values, mapping_registry, literal_mapping_registry, opt)
341:       end
342:     end

[Source]

     # File lib/soap/rpc/proxy.rb, line 328
328:     def request_default_encodingstyle
329:       (@request_use == :encoded) ? EncodingNamespace : LiteralNamespace
330:     end

[Source]

     # File lib/soap/rpc/proxy.rb, line 332
332:     def response_default_encodingstyle
333:       (@response_use == :encoded) ? EncodingNamespace : LiteralNamespace
334:     end

[Source]

     # File lib/soap/rpc/proxy.rb, line 344
344:     def response_obj(body, mapping_registry, literal_mapping_registry, opt)
345:       if @response_style == :rpc
346:         response_rpc(body, mapping_registry, literal_mapping_registry, opt)
347:       else
348:         response_doc(body, mapping_registry, literal_mapping_registry, opt)
349:       end
350:     end

Private Instance methods

[Source]

     # File lib/soap/rpc/proxy.rb, line 362
362:     def check_style(style)
363:       unless [:rpc, :document].include?(style)
364:         raise MethodDefinitionError.new("unknown style: #{style}")
365:       end
366:     end

[Source]

     # File lib/soap/rpc/proxy.rb, line 368
368:     def check_use(use)
369:       unless [:encoded, :literal].include?(use)
370:         raise MethodDefinitionError.new("unknown use: #{use}")
371:       end
372:     end

[Source]

     # File lib/soap/rpc/proxy.rb, line 483
483:     def create_request_obj(names, params)
484:       o = Object.new
485:       idx = 0
486:       while idx < params.length
487:         o.instance_variable_set('@' + names[idx], params[idx])
488:         idx += 1
489:       end
490:       o
491:     end

[Source]

     # File lib/soap/rpc/proxy.rb, line 382
382:     def request_doc(values, mapping_registry, literal_mapping_registry, opt)
383:       if @request_use == :encoded
384:         request_doc_enc(values, mapping_registry, opt)
385:       else
386:         request_doc_lit(values, literal_mapping_registry, opt)
387:       end
388:     end

[Source]

     # File lib/soap/rpc/proxy.rb, line 412
412:     def request_doc_enc(values, mapping_registry, opt)
413:       (0...values.size).collect { |idx|
414:         ele = Mapping.obj2soap(values[idx], mapping_registry, nil, opt)
415:         ele.elename = @doc_request_qnames[idx]
416:         ele
417:       }
418:     end

[Source]

     # File lib/soap/rpc/proxy.rb, line 420
420:     def request_doc_lit(values, mapping_registry, opt)
421:       (0...values.size).collect { |idx|
422:         ele = Mapping.obj2soap(values[idx], mapping_registry,
423:           @doc_request_qnames[idx], opt)
424:         ele.encodingstyle = LiteralNamespace
425:         if ele.respond_to?(:qualified)
426:           ele.qualified = @doc_request_qualified[idx]
427:         end
428:         ele
429:       }
430:     end

[Source]

     # File lib/soap/rpc/proxy.rb, line 374
374:     def request_rpc(values, mapping_registry, literal_mapping_registry, opt)
375:       if @request_use == :encoded
376:         request_rpc_enc(values, mapping_registry, opt)
377:       else
378:         request_rpc_lit(values, literal_mapping_registry, opt)
379:       end
380:     end

[Source]

     # File lib/soap/rpc/proxy.rb, line 390
390:     def request_rpc_enc(values, mapping_registry, opt)
391:       method = @rpc_method_factory.dup
392:       names = method.input_params
393:       obj = create_request_obj(names, values)
394:       soap = Mapping.obj2soap(obj, mapping_registry, @rpc_request_qname, opt)
395:       method.set_param(soap)
396:       method
397:     end

[Source]

     # File lib/soap/rpc/proxy.rb, line 399
399:     def request_rpc_lit(values, mapping_registry, opt)
400:       method = @rpc_method_factory.dup
401:       params = {}
402:       idx = 0
403:       method.input_params.each do |name|
404:         params[name] = Mapping.obj2soap(values[idx], mapping_registry, 
405:           XSD::QName.new(nil, name), opt)
406:         idx += 1
407:       end
408:       method.set_param(params)
409:       method
410:     end

[Source]

     # File lib/soap/rpc/proxy.rb, line 440
440:     def response_doc(body, mapping_registry, literal_mapping_registry, opt)
441:       if @response_use == :encoded
442:         return *response_doc_enc(body, mapping_registry, opt)
443:       else
444:         return *response_doc_lit(body, literal_mapping_registry, opt)
445:       end
446:     end

[Source]

     # File lib/soap/rpc/proxy.rb, line 471
471:     def response_doc_enc(body, mapping_registry, opt)
472:       body.collect { |key, value|
473:         Mapping.soap2obj(value, mapping_registry, nil, opt)
474:       }
475:     end

[Source]

     # File lib/soap/rpc/proxy.rb, line 477
477:     def response_doc_lit(body, mapping_registry, opt)
478:       body.collect { |key, value|
479:         Mapping.soap2obj(value, mapping_registry)
480:       }
481:     end

[Source]

     # File lib/soap/rpc/proxy.rb, line 432
432:     def response_rpc(body, mapping_registry, literal_mapping_registry, opt)
433:       if @response_use == :encoded
434:         response_rpc_enc(body, mapping_registry, opt)
435:       else
436:         response_rpc_lit(body, literal_mapping_registry, opt)
437:       end
438:     end

[Source]

     # File lib/soap/rpc/proxy.rb, line 448
448:     def response_rpc_enc(body, mapping_registry, opt)
449:       ret = nil
450:       if body.response
451:         ret = Mapping.soap2obj(body.response, mapping_registry,
452:           @rpc_method_factory.retval_class_name, opt)
453:       end
454:       if body.outparams
455:         outparams = body.outparams.collect { |outparam|
456:           Mapping.soap2obj(outparam, mapping_registry, nil, opt)
457:         }
458:         [ret].concat(outparams)
459:       else
460:         ret
461:       end
462:     end

[Source]

     # File lib/soap/rpc/proxy.rb, line 464
464:     def response_rpc_lit(body, mapping_registry, opt)
465:       body.root_node.collect { |key, value|
466:         Mapping.soap2obj(value, mapping_registry,
467:           @rpc_method_factory.retval_class_name, opt)
468:       }
469:     end

[Validate]