Class: WSDL::OperationBinding

Inherits:
Info show all
Defined in:
lib/wsdl/operationBinding.rb

Defined Under Namespace

Classes: BoundId, OperationInfo, Part

Instance Attribute Summary collapse

Attributes inherited from Info

#id, #parent, #root

Instance Method Summary collapse

Methods inherited from Info

#inspect, #parse_epilogue

Constructor Details

#initializeOperationBinding

Returns a new instance of OperationBinding.



78
79
80
81
82
83
84
85
# File 'lib/wsdl/operationBinding.rb', line 78

def initialize
  super
  @name = nil
  @input = nil
  @output = nil
  @fault = []
  @soapoperation = nil
end

Instance Attribute Details

#faultObject (readonly)

Returns the value of attribute fault.



19
20
21
# File 'lib/wsdl/operationBinding.rb', line 19

def fault
  @fault
end

#inputObject (readonly)

Returns the value of attribute input.



17
18
19
# File 'lib/wsdl/operationBinding.rb', line 17

def input
  @input
end

#nameObject (readonly)

required



16
17
18
# File 'lib/wsdl/operationBinding.rb', line 16

def name
  @name
end

#outputObject (readonly)

Returns the value of attribute output.



18
19
20
# File 'lib/wsdl/operationBinding.rb', line 18

def output
  @output
end

#soapoperationObject (readonly)

Returns the value of attribute soapoperation.



20
21
22
# File 'lib/wsdl/operationBinding.rb', line 20

def soapoperation
  @soapoperation
end

Instance Method Details

#boundidObject



121
122
123
# File 'lib/wsdl/operationBinding.rb', line 121

def boundid
  BoundId.new(name, soapaction)
end

#find_operationObject

Raises:

  • (RuntimeError)


125
126
127
128
129
130
131
132
133
134
135
# File 'lib/wsdl/operationBinding.rb', line 125

def find_operation
  porttype.operations.each do |op|
    next if op.name != @name
    next if op.input and @input and op.input.name and @input.name and
      op.input.name != @input.name
    next if op.output and @output and op.output.name and @output.name and
      op.output.name != @output.name
    return op
  end
  raise RuntimeError.new("#{@name} not found")
end

#operation_infoObject



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/wsdl/operationBinding.rb', line 87

def operation_info
  qname = soapoperation_name()
  style = soapoperation_style()
  use_input = soapbody_use(@input)
  use_output = soapbody_use(@output)
  info = OperationInfo.new(boundid, qname, style, use_input, use_output)
  op = find_operation()
  if style == :rpc
    info.parts.concat(collect_rpcparameter(op))
  else
    info.parts.concat(collect_documentparameter(op))
  end
  @fault.each do |fault|
    op_fault = {}
    soapfault = fault.soapfault
    next if soapfault.nil?
    op_fault[:ns] = fault.name.namespace
    op_fault[:name] = fault.name.name
    op_fault[:namespace] = soapfault.namespace
    op_fault[:use] = soapfault.use || "literal"
    op_fault[:encodingstyle] = soapfault.encodingstyle || "document"
    info.faults[fault.name] = op_fault
  end
  info
end

#parse_attr(attr, value) ⇒ Object



191
192
193
194
195
196
197
198
# File 'lib/wsdl/operationBinding.rb', line 191

def parse_attr(attr, value)
  case attr
  when NameAttrName
    @name = value.source
  else
    nil
  end
end

#parse_element(element) ⇒ Object



165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/wsdl/operationBinding.rb', line 165

def parse_element(element)
  case element
  when InputName
    o = Param.new
    @input = o
    o
  when OutputName
    o = Param.new
    @output = o
    o
  when FaultName
    o = Param.new
    @fault << o
    o
  when SOAPOperationName
    o = WSDL::SOAP::Operation.new
    @soapoperation = o
    o
  when DocumentationName
    o = Documentation.new
    o
  else
    nil
  end
end

#porttypeObject



117
118
119
# File 'lib/wsdl/operationBinding.rb', line 117

def porttype
  root.porttype(parent.type)
end

#soapactionObject



157
158
159
160
161
162
163
# File 'lib/wsdl/operationBinding.rb', line 157

def soapaction
  if @soapoperation
    @soapoperation.soapaction
  else
    nil
  end
end

#soapoperation_nameObject



137
138
139
140
141
142
143
# File 'lib/wsdl/operationBinding.rb', line 137

def soapoperation_name
  op_name = find_operation.operationname
  if @input and @input.soapbody and @input.soapbody.namespace
    op_name = XSD::QName.new(@input.soapbody.namespace, op_name.name)
  end
  op_name
end

#soapoperation_styleObject



145
146
147
148
149
150
151
152
153
154
155
# File 'lib/wsdl/operationBinding.rb', line 145

def soapoperation_style
  style = nil
  if @soapoperation
    style = @soapoperation.operation_style
  elsif parent.soapbinding
    style = parent.soapbinding.style
  else
    raise TypeError.new("operation style definition not found")
  end
  style || :document
end

#targetnamespaceObject



113
114
115
# File 'lib/wsdl/operationBinding.rb', line 113

def targetnamespace
  parent.targetnamespace
end