Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

Changeset 2001

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/soap/wsdlDriver.rb

    r1975 r2001  
    6868      service.ports.each do |port| 
    6969        next if targetport and port.name != targetport 
    70         sig << port.porttype.operations.collect { |operation| 
    71           dump_method_signature(operation, element_definitions).gsub(/^#/, ' ') 
    72         }.join("\n") 
     70        if porttype = port.porttype 
     71          assigned_method = collect_assigned_method(porttype.name) 
     72          if binding = port.porttype.find_binding 
     73            sig << binding.operations.collect { |op_bind| 
     74              operation = op_bind.find_operation 
     75              name = assigned_method[op_bind.boundid] || op_bind.name 
     76              str = "= #{safemethodname(name)}\n\n" 
     77              str << dump_method_signature(name, operation, element_definitions) 
     78              str.gsub(/^#/, " ") 
     79            }.join("\n") 
     80          end 
     81        end 
    7382      end 
    7483    end 
     
    7786 
    7887private 
     88 
     89  def collect_assigned_method(porttypename) 
     90    name_creator = WSDL::SOAP::ClassNameCreator.new 
     91    methoddefcreator = 
     92      WSDL::SOAP::MethodDefCreator.new(@wsdl, name_creator, nil, {}) 
     93    methoddefcreator.dump(porttypename) 
     94    methoddefcreator.assigned_method 
     95  end 
    7996 
    8097  def find_port(servicename = nil, portname = nil) 
  • 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 
  • branches/1_5/test/wsdl/overload/overload.wsdl

    r1701 r2001  
    11<?xml version="1.0" encoding="UTF-8"?> 
    2 <wsdl:definitions targetNamespace="http://confluence.atlassian.com/rpc/soap-axis/confluenceservice-v1" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://confluence.atlassian.com/rpc/soap-axis/confluenceservice-v1" xmlns:intf="http://confluence.atlassian.com/rpc/soap-axis/confluenceservice-v1" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="http://rpc.confluence.atlassian.com" xmlns:tns2="http://beans.soap.rpc.confluence.atlassian.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
     2<wsdl:definitions targetNamespace="urn:overload" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:tns="urn:overload" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    33 <wsdl:types> 
    4   <schema targetNamespace="http://rpc.confluence.atlassian.com" xmlns="http://www.w3.org/2001/XMLSchema"> 
     4  <schema targetNamespace="urn:overload" xmlns="http://www.w3.org/2001/XMLSchema"> 
    55   <import namespace="http://xml.apache.org/xml-soap"/> 
    6    <import namespace="http://beans.soap.rpc.confluence.atlassian.com"/> 
    7    <import namespace="http://confluence.atlassian.com/rpc/soap-axis/confluenceservice-v1"/> 
    86   <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/> 
    97  </schema> 
     
    2927   </wsdl:message> 
    3028 
    31  
    32    <wsdl:portType name="ConfluenceSoapService"> 
     29   <wsdl:portType name="OverloadServicePortType"> 
    3330      <wsdl:operation name="methodAlpha" parameterOrder="in0 in1 in2"> 
    34          <wsdl:input message="impl:methodAlphaRequest" name="methodAlphaRequest"/> 
    35          <wsdl:output message="impl:methodAlphaResponse" name="methodAlphaResponse"/> 
     31         <wsdl:input message="tns:methodAlphaRequest" name="methodAlphaRequest"/> 
     32         <wsdl:output message="tns:methodAlphaResponse" name="methodAlphaResponse"/> 
    3633      </wsdl:operation> 
    3734 
    3835      <wsdl:operation name="methodAlpha" parameterOrder="in0 in1"> 
    39          <wsdl:input message="impl:methodAlphaRequest1" name="methodAlphaRequest1"/> 
    40          <wsdl:output message="impl:methodAlphaResponse1" name="methodAlphaResponse1"/> 
     36         <wsdl:input message="tns:methodAlphaRequest1" name="methodAlphaRequest1"/> 
     37         <wsdl:output message="tns:methodAlphaResponse1" name="methodAlphaResponse1"/> 
    4138      </wsdl:operation> 
    42  
    4339   </wsdl:portType> 
    4440 
    45    <wsdl:binding name="confluencesoapservice-v1SoapBinding" type="impl:ConfluenceSoapService"> 
     41   <wsdl:binding name="OverloadServiceSoap" type="tns:OverloadServicePortType"> 
    4642      <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> 
    4743      <wsdl:operation name="methodAlpha"> 
    4844         <wsdlsoap:operation soapAction="methodAlpha1"/> 
    49           
    5045         <wsdl:input name="methodAlphaRequest"> 
    51             <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://soap.rpc.confluence.atlassian.com" use="encoded"/> 
     46            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:overload" use="encoded"/> 
    5247         </wsdl:input> 
    53           
    5448         <wsdl:output name="methodAlphaResponse"> 
    55             <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://confluence.atlassian.com/rpc/soap-axis/confluenceservice-v1" use="encoded"/> 
     49            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:overload" use="encoded"/> 
    5650         </wsdl:output> 
    57           
    5851      </wsdl:operation> 
    5952 
    6053      <wsdl:operation name="methodAlpha"> 
    6154         <wsdlsoap:operation soapAction="methodAlpha2"/> 
    62           
    6355         <wsdl:input name="methodAlphaRequest1"> 
    64             <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://soap.rpc.confluence.atlassian.com" use="encoded"/> 
     56            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:overload" use="encoded"/> 
    6557         </wsdl:input> 
    66           
    6758         <wsdl:output name="methodAlphaResponse1"> 
    68             <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://confluence.atlassian.com/rpc/soap-axis/confluenceservice-v1" use="encoded"/> 
     59            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:overload" use="encoded"/> 
    6960         </wsdl:output> 
    70           
    7161      </wsdl:operation> 
    7262    </wsdl:binding> 
    7363         
    74        <wsdl:service name="ConfluenceSoapServiceService"> 
    75       <wsdl:port binding="impl:confluencesoapservice-v1SoapBinding" name="confluencesoapservice-v1"> 
    76         <wsdlsoap:address location="http://confluence.atlassian.com/rpc/soap-axis/confluenceservice-v1"/> 
     64    <wsdl:service name="OverloadService"> 
     65      <wsdl:port binding="tns:OverloadServiceSoap" name="OverloadServicePort"> 
     66        <wsdlsoap:address location="http://localhost/"/> 
    7767      </wsdl:port> 
    7868   </wsdl:service> 
  • branches/1_5/test/wsdl/overload/test_overload.rb

    r1963 r2001  
    1111 
    1212class TestOverload < Test::Unit::TestCase 
    13   TNS = "http://confluence.atlassian.com/rpc/soap-axis/confluenceservice-v1
     13  TNS = "urn:overload
    1414 
    1515  Methods = [ 
     
    5757  def teardown 
    5858    teardown_server if @server 
    59     File.unlink(pathname('default.rb')) unless $DEBUG 
     59    unless $DEBUG 
     60      File.unlink(pathname('default.rb')) 
     61      File.unlink(pathname('defaultMappingRegistry.rb')) 
     62      File.unlink(pathname('defaultDriver.rb')) 
     63      File.unlink(pathname('defaultServant.rb')) 
     64      File.unlink(pathname('OverloadServiceClient.rb')) 
     65    end 
    6066    @client.reset_stream if @client 
    6167  end 
     
    7379    gen.logger.level = Logger::FATAL 
    7480    gen.opt['classdef'] = nil 
     81    gen.opt['mapping_registry'] = nil 
     82    gen.opt['driver'] = nil 
     83    gen.opt['servant_skelton'] = nil 
     84    gen.opt['client_skelton'] = nil 
    7585    gen.opt['force'] = true 
    7686    gen.run 
     
    8696  def pathname(filename) 
    8797    File.join(DIR, filename) 
     98  end 
     99 
     100  def test_compare 
     101    compare("expectedDriver.rb", "defaultDriver.rb") 
     102    compare("expectedServant.rb", "defaultServant.rb") 
     103    compare("expectedClient.rb", "OverloadServiceClient.rb") 
    88104  end 
    89105 
     
    106122    assert_equal(2, @client.call("methodAlpha2", "1", "2")) 
    107123  end 
     124 
     125  def compare(expected, actual) 
     126    TestUtil.filecompare(pathname(expected), pathname(actual)) 
     127  end 
    108128end 
    109129