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, AttrActorName, AttrArrayType, AttrArrayTypeName, AttrEncodingStyle, AttrEncodingStyleName, AttrHref, AttrHrefName, AttrId, AttrIdName, 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, SOAPProxy, TypeMap, VERSION, ValueArray, ValueArrayName, XSDNamespaceTag, XSINamespaceTag

Instance Attribute Summary collapse

Attributes included from SOAPCompoundtype

#qualified

Attributes included from SOAPType

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

Attributes inherited from XSD::NSDBase

#type

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 SOAPType

#inspect, #rootnode

Methods inherited from XSD::NSDBase

inherited, #init, types

Constructor Details

#initialize(qname, param_def = nil) ⇒ SOAPMethod

Returns a new instance of SOAPMethod.



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

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_params(@param_def) if @param_def
end

Instance Attribute Details

#inparamObject (readonly)

Returns the value of attribute inparam.



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

def inparam
  @inparam
end

#outparamObject (readonly)

Returns the value of attribute outparam.



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

def outparam
  @outparam
end

#param_defObject (readonly)

Returns the value of attribute param_def.



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

def param_def
  @param_def
end

#retval_class_nameObject (readonly)

Returns the value of attribute retval_class_name.



83
84
85
# File 'lib/soap/rpc/element.rb', line 83

def retval_class_name
  @retval_class_name
end

#retval_nameObject (readonly)

Returns the value of attribute retval_name.



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

def retval_name
  @retval_name
end

Class Method Details

.create_doc_param_def(req_qnames, res_qnames) ⇒ Object



187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/soap/rpc/element.rb', line 187

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 and res_qnames can be nil
  if req_qnames
    req_qnames.each do |qname|
      param_def << [IN, qname.name, [nil, qname.namespace, qname.name]]
    end
  end
  if res_qnames
    res_qnames.each do |qname|
      param_def << [OUT, qname.name, [nil, qname.namespace, qname.name]]
    end
  end
  param_def
end

.create_rpc_param_def(param_names) ⇒ Object



178
179
180
181
182
183
184
185
# File 'lib/soap/rpc/element.rb', line 178

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



165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/soap/rpc/element.rb', line 165

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



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

def SOAPMethod.param_count(param_def, *type)
  count = 0
  param_def.each do |param|
    param = MethodDef.to_param(param)
    if type.include?(param.io_type.to_sym)
      count += 1
    end
  end
  count
end

Instance Method Details

#get_paramtypes(names) ⇒ Object



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

def get_paramtypes(names)
  types = []
  @signature.each do |io_type, name, type_qname|
    if type_qname && idx = names.index(name)
      types[idx] = type_qname
    end
  end
  types
end

#have_memberObject



105
106
107
# File 'lib/soap/rpc/element.rb', line 105

def have_member
  true
end

#have_outparam?Boolean

Returns:

  • (Boolean)


109
110
111
# File 'lib/soap/rpc/element.rb', line 109

def have_outparam?
  @outparam_names.size > 0
end

#input_param_typesObject



121
122
123
# File 'lib/soap/rpc/element.rb', line 121

def input_param_types
  collect_param_types(IN, INOUT)
end

#input_paramsObject



113
114
115
# File 'lib/soap/rpc/element.rb', line 113

def input_params
  collect_params(IN, INOUT)
end

#output_param_typesObject



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

def output_param_types
  collect_param_types(OUT, INOUT)
end

#output_paramsObject



117
118
119
# File 'lib/soap/rpc/element.rb', line 117

def output_params
  collect_params(OUT, INOUT)
end

#set_outparam(params) ⇒ Object



137
138
139
140
141
142
# File 'lib/soap/rpc/element.rb', line 137

def set_outparam(params)
  params.each do |param, data|
    @outparam[param] = data
    data.elename = XSD::QName.new(data.elename.namespace, param)
  end
end

#set_param(params) ⇒ Object



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

def set_param(params)
  params.each do |param, data|
    @inparam[param] = data
    data.elename = XSD::QName.new(data.elename.namespace, param)
    data.parent = self
  end
end