Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]
Show
Ignore:
Timestamp:
10/14/07 09:34:27 (1 year ago)
Author:
nahi
Message:
  • wsdl2ruby.rb did not generate proper definitions for overloaded method in WSDL. closes #446.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1_5/lib/wsdl/operationBinding.rb

    r1824 r2001  
    2020  attr_reader :soapoperation 
    2121 
     22  class BoundId 
     23    attr_reader :name 
     24    attr_reader :soapaction 
     25 
     26    def initialize(name, soapaction) 
     27      @name = name 
     28      @soapaction = soapaction 
     29    end 
     30 
     31    def ==(rhs) 
     32      !rhs.nil? and @name == rhs.name and @soapaction == rhs.soapaction 
     33    end 
     34 
     35    def eql?(rhs) 
     36      (self == rhs) 
     37    end 
     38 
     39    def hash 
     40      @name.hash ^ @soapaction.hash 
     41    end 
     42  end 
     43 
    2244  def initialize 
    2345    super 
     
    3557  def porttype 
    3658    root.porttype(parent.type) 
     59  end 
     60 
     61  def boundid 
     62    BoundId.new(name, soapaction) 
    3763  end 
    3864 
  • branches/1_5/lib/wsdl/soap/classDefCreatorSupport.rb

    r1954 r2001  
    3434  end 
    3535 
    36   def dump_method_signature(operation, element_definitions) 
    37     name = operation.name 
     36  def dump_method_signature(name, operation, element_definitions) 
     37    methodname = safemethodname(name) 
    3838    input = operation.input 
    3939    output = operation.output 
    4040    fault = operation.fault 
    41     signature = "#{ name }#{ dump_inputparam(input) }" 
     41    signature = "#{methodname}#{dump_inputparam(input)}" 
    4242    str = <<__EOD__ 
    4343# SYNOPSIS 
    44 #   #{name}#{dump_inputparam(input)} 
     44#   #{methodname}#{dump_inputparam(input)} 
    4545# 
    4646# ARGS 
     
    224224    raise RuntimeError.new("cannot define name of #{attribute}") 
    225225  end 
     226 
     227  # TODO: run MethodDefCreator just once in 1.6.X. 
     228  # MethodDefCreator should return parsed struct, not a String. 
     229  def collect_assigned_method(wsdl, porttypename, modulepath = nil) 
     230    name_creator = WSDL::SOAP::ClassNameCreator.new 
     231    methoddefcreator = 
     232      WSDL::SOAP::MethodDefCreator.new(wsdl, name_creator, modulepath, {}) 
     233    methoddefcreator.dump(porttypename) 
     234    methoddefcreator.assigned_method 
     235  end 
    226236end 
    227237 
  • branches/1_5/lib/wsdl/soap/clientSkeltonCreator.rb

    r1948 r2001  
    5252 
    5353  def dump_porttype(porttype) 
     54    assigned_method = collect_assigned_method(@definitions, porttype.name, @modulepath) 
    5455    drv_name = mapped_class_basename(porttype.name, @modulepath) 
    5556 
     
    6465__EOD__ 
    6566    element_definitions = @definitions.collect_elements 
    66     porttype.operations.each do |operation| 
    67       result << dump_method_signature(operation, element_definitions) 
    68       result << dump_input_init(operation.input) << "\n" 
    69       result << dump_operation(operation) << "\n\n" 
     67    binding = porttype.find_binding 
     68    if binding 
     69      binding.operations.each do |op_bind| 
     70        operation = op_bind.find_operation 
     71        if operation.nil? 
     72          warn("operation not found for binding: #{op_bind}") 
     73          next 
     74        end 
     75        name = assigned_method[op_bind.boundid] || operation.name 
     76        result << dump_method_signature(name, operation, element_definitions) 
     77        result << dump_input_init(operation.input) << "\n" 
     78        result << dump_operation(name, operation) << "\n\n" 
     79      end 
    7080    end 
    7181    result 
    7282  end 
    7383 
    74   def dump_operation(operation) 
    75     name = operation.name 
     84  def dump_operation(name, operation) 
    7685    input = operation.input 
    7786    "puts obj.#{ safemethodname(name) }#{ dump_inputparam(input) }" 
  • branches/1_5/lib/wsdl/soap/driverCreator.rb

    r1948 r2001  
    6363    class_name = mapped_class_basename(qname, @modulepath) 
    6464    defined_const = {} 
    65     result = MethodDefCreator.new(@definitions, @name_creator, @modulepath, defined_const).dump(porttype) 
     65    mdcreator = MethodDefCreator.new(@definitions, @name_creator, @modulepath, defined_const) 
     66    result = mdcreator.dump(porttype) 
    6667    methoddef = result[:methoddef] 
    6768    binding = @definitions.bindings.find { |item| item.type == porttype } 
    6869    if binding.nil? or binding.soapbinding.nil? 
    69       # not bind or not a SOAP binding 
     70      # not bound or not a SOAP binding 
    7071      return '' 
    7172    end 
  • branches/1_5/lib/wsdl/soap/methodDefCreator.rb

    r1983 r2001  
    2020 
    2121  attr_reader :definitions 
     22  # TODO: should not export this kind of stateful information. 
     23  # will be rewwritten in 1.6.1 
     24  attr_reader :assigned_method 
    2225 
    2326  def initialize(definitions, name_creator, modulepath, defined_const) 
     
    3235    @literal = false 
    3336    @defined_const = defined_const 
     37    @assigned_method = {} 
    3438  end 
    3539 
     
    9498private 
    9599 
    96   def dump_method(operation, binding
     100  def dump_method(operation, op_bind
    97101    op_faults = {} 
    98     binding.fault.each do |fault| 
     102    op_bind.fault.each do |fault| 
    99103      op_fault = {} 
    100104      soapfault = fault.soapfault 
     
    109113    end 
    110114    op_faults_str = op_faults.inspect 
    111  
    112     name = safemethodname(operation.name) 
    113     name_as = operation.name 
    114     style = binding.soapoperation_style 
    115     inputuse = binding.soapbody_use_input 
    116     outputuse = binding.soapbody_use_output 
     115    name = assign_method_name(op_bind) 
     116    style = op_bind.soapoperation_style 
     117    inputuse = op_bind.soapbody_use_input 
     118    outputuse = op_bind.soapbody_use_output 
    117119    if style == :rpc 
    118       qname = binding.soapoperation_name 
     120      qname = op_bind.soapoperation_name 
    119121      paramstr = param2str(collect_rpcparameter(operation)) 
    120122    else 
     
    128130    end 
    129131    definitions = <<__EOD__ 
    130 #{ndq(binding.soapaction)}, 
     132#{ndq(op_bind.soapaction)}, 
    131133  #{dq(name)}, 
    132134  #{paramstr}, 
     
    152154__EOD__ 
    153155    end 
     156  end 
     157 
     158  def assign_method_name(op_bind) 
     159    method_name = safemethodname(op_bind.name) 
     160    i = 1 # starts from _2 
     161    while @assigned_method.value?(method_name) 
     162      i += 1 
     163      method_name = safemethodname("#{op_bind.name}_#{i}") 
     164    end 
     165    @assigned_method[op_bind.boundid] = method_name 
     166    method_name 
    154167  end 
    155168 
  • branches/1_5/lib/wsdl/soap/servantSkeltonCreator.rb

    r1948 r2001  
    3636    end 
    3737    if porttype.nil? 
    38       @definitions.porttypes.each do |type| 
    39         result << dump_porttype(type.name) 
     38      @definitions.porttypes.each do |porttype| 
     39        result << dump_porttype(porttype) 
    4040        result << "\n" 
    4141      end 
     
    5353private 
    5454 
    55   def dump_porttype(name) 
    56     class_name = mapped_class_basename(name, @modulepath) 
     55  def dump_porttype(porttype) 
     56    assigned_method = collect_assigned_method(@definitions, porttype.name, @modulepath) 
     57    class_name = mapped_class_basename(porttype.name, @modulepath) 
    5758    c = XSD::CodeGen::ClassDef.new(class_name) 
    5859    element_definitions = @definitions.collect_elements 
    59     operations = @definitions.porttype(name).operations 
    60     operations.each do |operation| 
    61       name = safemethodname(operation.name) 
    62       input = operation.input 
    63       params = input.find_message.parts.collect { |part| 
    64         safevarname(part.name) 
    65       } 
    66       m = XSD::CodeGen::MethodDef.new(name, params) do <<-EOD 
    67             p [#{params.join(", ")}] 
    68             raise NotImplementedError.new 
    69           EOD 
     60    binding = porttype.find_binding 
     61    if binding 
     62      binding.operations.each do |op_bind| 
     63        operation = op_bind.find_operation 
     64        if operation.nil? 
     65          warn("operation not found for binding: #{op_bind}") 
     66          next 
    7067        end 
    71       m.comment = dump_method_signature(operation, element_definitions) 
    72       c.add_method(m) 
     68        name = assigned_method[op_bind.boundid] || operation.name 
     69        methodname = safemethodname(name) 
     70        input = operation.input 
     71        params = input.find_message.parts.collect { |part| 
     72          safevarname(part.name) 
     73        } 
     74        m = XSD::CodeGen::MethodDef.new(methodname, params) do <<-EOD 
     75              p [#{params.join(", ")}] 
     76              raise NotImplementedError.new 
     77            EOD 
     78          end 
     79        m.comment = dump_method_signature(methodname, operation, element_definitions) 
     80        c.add_method(m) 
     81      end 
    7382    end 
    7483    c.dump