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.



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

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

Instance Attribute Details

#faultObject (readonly)

Returns the value of attribute fault.



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

def fault
  @fault
end

#inputObject (readonly)

Returns the value of attribute input.



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

def input
  @input
end

#nameObject (readonly)

required



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

def name
  @name
end

#outputObject (readonly)

Returns the value of attribute output.



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

def output
  @output
end

#soapoperationObject (readonly)

Returns the value of attribute soapoperation.



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

def soapoperation
  @soapoperation
end

Instance Method Details

#boundidObject



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

def boundid
  BoundId.new(name, soapaction)
end

#find_operationObject

Raises:

  • (RuntimeError)


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

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



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

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



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

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

#parse_element(element) ⇒ Object



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

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



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

def porttype
  root.porttype(parent.type)
end

#soapactionObject



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

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

#soapoperation_nameObject



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

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



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

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



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

def targetnamespace
  parent.targetnamespace
end