Class: SOAP::RPC::SOAPMethod

Inherits:
SOAPStruct show all
Defined in:
lib/soap/rpc/element.rb

Direct Known Subclasses

SOAPMethodRequest, SOAPMethodResponse

Constant Summary collapse

RETVAL =
'retval'
IN =
'in'
OUT =
'out'
INOUT =
'inout'

Constants included from SOAP

AttrActor, AttrArrayType, AttrArrayTypeName, AttrEncodingStyle, AttrEncodingStyleName, AttrMustUnderstand, AttrMustUnderstandName, AttrOffset, AttrOffsetName, AttrPosition, AttrPositionName, AttrRoot, AttrRootName, Base64Literal, EleBody, EleBodyName, EleEnvelope, EleEnvelopeName, EleFault, EleFaultActor, EleFaultActorName, EleFaultCode, EleFaultCodeName, EleFaultDetail, EleFaultDetailName, EleFaultName, EleFaultString, EleFaultStringName, EleHeader, EleHeaderName, EncodingNamespace, EnvelopeNamespace, LiteralNamespace, MediaType, NextActor, PropertyName, SOAPNamespaceTag, TypeMap, VERSION, ValueArray, ValueArrayName, XSDNamespaceTag, XSINamespaceTag

Instance Attribute Summary collapse

Attributes included from SOAPType

#definedtype, #elename, #encodingstyle, #extraattr, #id, #parent, #position, #precedents, #root

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SOAPStruct

#[], #[]=, #add, decode, #each, #key?, #members, #replace, #to_obj, #to_s

Methods included from Enumerable

#inject

Methods included from SOAPType

#inspect, #rootnode

Constructor Details

#initialize(qname, param_def = nil) ⇒ SOAPMethod

Returns a new instance of SOAPMethod.


83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/soap/rpc/element.rb', line 83

def initialize(qname, param_def = nil)
  super(nil)
  @elename = qname
  @encodingstyle = nil

  @param_def = param_def

  @signature = []
  @inparam_names = []
  @inoutparam_names = []
  @outparam_names = []

  @inparam = {}
  @outparam = {}
  @retval_name = nil
  @retval_class_name = nil

  init_param(@param_def) if @param_def
end

Instance Attribute Details

#inparamObject (readonly)

Returns the value of attribute inparam


78
79
80
# File 'lib/soap/rpc/element.rb', line 78

def inparam
  @inparam
end

#outparamObject (readonly)

Returns the value of attribute outparam


79
80
81
# File 'lib/soap/rpc/element.rb', line 79

def outparam
  @outparam
end

#param_defObject (readonly)

Returns the value of attribute param_def


77
78
79
# File 'lib/soap/rpc/element.rb', line 77

def param_def
  @param_def
end

#retval_class_nameObject (readonly)

Returns the value of attribute retval_class_name


81
82
83
# File 'lib/soap/rpc/element.rb', line 81

def retval_class_name
  @retval_class_name
end

#retval_nameObject (readonly)

Returns the value of attribute retval_name


80
81
82
# File 'lib/soap/rpc/element.rb', line 80

def retval_name
  @retval_name
end

Class Method Details

.create_doc_param_def(req_qnames, res_qnames) ⇒ Object


162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/soap/rpc/element.rb', line 162

def SOAPMethod.create_doc_param_def(req_qnames, res_qnames)
  req_qnames = [req_qnames] if req_qnames.is_a?(XSD::QName)
  res_qnames = [res_qnames] if res_qnames.is_a?(XSD::QName)
  param_def = []
  req_qnames.each do |qname|
    param_def << [IN, qname.name, [nil, qname.namespace, qname.name]]
  end
  res_qnames.each do |qname|
    param_def << [OUT, qname.name, [nil, qname.namespace, qname.name]]
  end
  param_def
end

.create_rpc_param_def(param_names) ⇒ Object


153
154
155
156
157
158
159
160
# File 'lib/soap/rpc/element.rb', line 153

def SOAPMethod.create_rpc_param_def(param_names)
  param_def = []
  param_names.each do |param_name|
    param_def.push([IN, param_name, nil])
  end
  param_def.push([RETVAL, 'return', nil])
  param_def
end

.derive_rpc_param_def(obj, name, *param) ⇒ Object


140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/soap/rpc/element.rb', line 140

def SOAPMethod.derive_rpc_param_def(obj, name, *param)
  if param.size == 1 and param[0].is_a?(Array)
    return param[0]
  end
  if param.empty?
    method = obj.method(name)
    param_names = (1..method.arity.abs).collect { |i| "p#{i}" }
  else
    param_names = param
  end
  create_rpc_param_def(param_names)
end

.param_count(param_def, *type) ⇒ Object


130
131
132
133
134
135
136
137
138
# File 'lib/soap/rpc/element.rb', line 130

def SOAPMethod.param_count(param_def, *type)
  count = 0
  param_def.each do |io_type, name, param_type|
    if type.include?(io_type)
      count += 1
    end
  end
  count
end

Instance Method Details

#have_outparam?Boolean

Returns:

  • (Boolean)

103
104
105
# File 'lib/soap/rpc/element.rb', line 103

def have_outparam?
  @outparam_names.size > 0
end

#input_paramsObject


107
108
109
# File 'lib/soap/rpc/element.rb', line 107

def input_params
  collect_params(IN, INOUT)
end

#output_paramsObject


111
112
113
# File 'lib/soap/rpc/element.rb', line 111

def output_params
  collect_params(OUT, INOUT)
end

#set_outparam(params) ⇒ Object


123
124
125
126
127
128
# File 'lib/soap/rpc/element.rb', line 123

def set_outparam(params)
  params.each do |param, data|
    @outparam[param] = data
    data.elename.name = param
  end
end

#set_param(params) ⇒ Object


115
116
117
118
119
120
121
# File 'lib/soap/rpc/element.rb', line 115

def set_param(params)
  params.each do |param, data|
    @inparam[param] = data
    data.elename.name = param
    data.parent = self
  end
end