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, 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, NS, NextActor, PropertyName, SOAP::RPCRouter, SOAP::RPCServerException, SOAP::RPCUtils, 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, #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 Enumerable

#inject

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.



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



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/soap/rpc/element.rb', line 172

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



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

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



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

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



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

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



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

def get_paramtypes(names)
  types = []
  @signature.each do |io_type, name, param_type|
    if param_type && idx = names.index(name)
      types[idx] = XSD::QName.new(param_type[1], param_type[2])
    end
  end
  types
end

#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 = XSD::QName.new(data.elename.namespace, 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 = XSD::QName.new(data.elename.namespace, param)
    data.parent = self
  end
end