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, SOAPProxy, TypeMap, VERSION, ValueArray, ValueArrayName

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.



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

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.



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

def inparam
  @inparam
end

#outparamObject (readonly)

Returns the value of attribute outparam.



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

def outparam
  @outparam
end

#param_defObject (readonly)

Returns the value of attribute param_def.



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

def param_def
  @param_def
end

#retval_class_nameObject (readonly)

Returns the value of attribute retval_class_name.



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

def retval_class_name
  @retval_class_name
end

#retval_nameObject (readonly)

Returns the value of attribute retval_name.



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

def retval_name
  @retval_name
end

Class Method Details

.create_doc_param_def(req_qnames, res_qnames) ⇒ Object



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

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



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

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



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

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



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

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



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

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



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

def have_member
  true
end

#have_outparam?Boolean

Returns:

  • (Boolean)


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

def have_outparam?
  @outparam_names.size > 0
end

#input_param_typesObject



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

def input_param_types
  collect_param_types(IN, INOUT)
end

#input_paramsObject



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

def input_params
  collect_params(IN, INOUT)
end

#output_param_typesObject



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

def output_param_types
  collect_param_types(OUT, INOUT)
end

#output_paramsObject



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

def output_params
  collect_params(OUT, INOUT)
end

#set_outparam(params) ⇒ Object



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

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



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

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