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, Charset, EleBody, EleBodyName, EleEnvelope, EleEnvelopeName, EleFault, EleFaultActor, EleFaultActorName, EleFaultCode, EleFaultCodeName, EleFaultDetail, EleFaultDetailName, EleFaultName, EleFaultString, EleFaultStringName, EleHeader, EleHeaderName, EncodingNamespace, EnvelopeNamespace, LiteralNamespace, MediaType, NextActor, PropertyName, SOAP::RPCRouter, SOAP::RPCServerException, SOAP::RPCUtils, SOAPGenerator, SOAPProxy, TypeMap, VERSION, ValueArray, ValueArrayName

Instance Attribute Summary collapse

Attributes included from SOAPCompoundtype

#qualified

Attributes included from SOAPType

#definedtype, #elename, #encodingstyle, #extraattr, #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 included from Enumerable

#inject

Methods inherited from XSD::NSDBase

inherited, #init, types

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



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

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



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

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



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

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



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

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

#get_paramtypes(names) ⇒ Object



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

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



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

def have_member
  true
end

#have_outparam?Boolean

Returns:

  • (Boolean)


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

def have_outparam?
  @outparam_names.size > 0
end

#input_param_typesObject



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

def input_param_types
  collect_param_types(IN, INOUT)
end

#input_paramsObject



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

def input_params
  collect_params(IN, INOUT)
end

#output_param_typesObject



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

def output_param_types
  collect_param_types(OUT, INOUT)
end

#output_paramsObject



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

def output_params
  collect_params(OUT, INOUT)
end

#set_outparam(params) ⇒ Object



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

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



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

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