class WSDL::OperationBinding

Attributes

fault[R]
input[R]
name[R]
output[R]
soapoperation[R]

Public Class Methods

new() click to toggle source
Calls superclass method WSDL::Info::new
# File lib/wsdl/operationBinding.rb, line 78
def initialize
  super
  @name = nil
  @input = nil
  @output = nil
  @fault = []
  @soapoperation = nil
end

Public Instance Methods

boundid() click to toggle source
# File lib/wsdl/operationBinding.rb, line 121
def boundid
  BoundId.new(name, soapaction)
end
find_operation() click to toggle source
# 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_info() click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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
porttype() click to toggle source
# File lib/wsdl/operationBinding.rb, line 117
def porttype
  root.porttype(parent.type)
end
soapaction() click to toggle source
# File lib/wsdl/operationBinding.rb, line 157
def soapaction
  if @soapoperation
    @soapoperation.soapaction
  else
    nil
  end
end
soapoperation_name() click to toggle source
# 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_style() click to toggle source
# 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
targetnamespace() click to toggle source
# File lib/wsdl/operationBinding.rb, line 113
def targetnamespace
  parent.targetnamespace
end

Private Instance Methods

cdr(ary) click to toggle source
# File lib/wsdl/operationBinding.rb, line 232
def cdr(ary)
  result = ary.dup
  result.shift
  result
end
collect_documentparameter(operation) click to toggle source
# File lib/wsdl/operationBinding.rb, line 221
def collect_documentparameter(operation)
  param = []
  operation.inputparts.each do |input|
    param << Part.new(:in, input.name, input.type, input.element)
  end
  operation.outputparts.each do |output|
    param << Part.new(:out, output.name, output.type, output.element)
  end
  param
end
collect_rpcparameter(operation) click to toggle source
# File lib/wsdl/operationBinding.rb, line 206
def collect_rpcparameter(operation)
  result = operation.inputparts.collect { |part|
    Part.new(:in, part.name, part.type, part.element)
  }
  outparts = operation.outputparts
  if outparts.size > 0
    retval = outparts[0]
    result << Part.new(:retval, retval.name, retval.type, retval.element)
    cdr(outparts).each { |part|
      result << Part.new(:out, part.name, part.type, part.element)
    }
  end
  result
end
soapbody_use(param) click to toggle source
# File lib/wsdl/operationBinding.rb, line 202
def soapbody_use(param)
  param ? param.soapbody_use : nil
end