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

Changeset 2007

Show
Ignore:
Timestamp:
10/30/07 12:05:34 (1 year ago)
Author:
nahi
Message:
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/soap/wsdlDriver.rb

    r2005 r2007  
    3232  def initialize(wsdl) 
    3333    @wsdl = import(wsdl) 
    34     name_creator = WSDL::SOAP::ClassNameCreator.new 
    35     @modulepath = 'WSDLDriverFactory' 
    36     @methoddefcreator = 
    37       WSDL::SOAP::MethodDefCreator.new(@wsdl, name_creator, @modulepath, {}) 
    3834  end 
    3935   
     
    4541    port = find_port(servicename, portname) 
    4642    drv = SOAP::RPC::Driver.new(port.soap_address.location) 
    47     init_driver(drv, port) 
    48     add_operation(drv, port) 
     43    if binding = port.find_binding 
     44      init_driver(drv, binding) 
     45      add_operation(drv, binding) 
     46    end 
    4947    drv 
    5048  end 
     
    114112  end 
    115113 
    116   def init_driver(drv, port
     114  def init_driver(drv, binding
    117115    wsdl_elements = @wsdl.collect_elements 
    118116    wsdl_types = @wsdl.collect_complextypes + @wsdl.collect_simpletypes 
    119117    rpc_decode_typemap = wsdl_types + 
    120       @wsdl.soap_rpc_complextypes(port.find_binding) 
     118      @wsdl.soap_rpc_complextypes(binding) 
    121119    drv.proxy.mapping_registry = 
    122120      Mapping::WSDLEncodedRegistry.new(rpc_decode_typemap) 
     
    125123  end 
    126124 
    127   def add_operation(drv, port) 
    128     port.find_binding.operations.each do |op_bind| 
    129       mdef = @methoddefcreator.create_methoddef(op_bind) 
     125  def add_operation(drv, binding) 
     126    name_creator = WSDL::SOAP::ClassNameCreator.new 
     127    modulepath = 'WSDLDriverFactory' 
     128    methoddefcreator = 
     129      WSDL::SOAP::MethodDefCreator.new(@wsdl, name_creator, modulepath, {}) 
     130    mdefs = methoddefcreator.create(binding.name) 
     131    if mdefs.nil? 
     132      raise FactoryError.new("no method definition found in WSDL") 
     133    end 
     134    mdefs.each do |mdef| 
    130135      opt = { 
    131136        :request_style => mdef.style, 
  • trunk/lib/wsdl/soap/cgiStubCreator.rb

    r1948 r2007  
    5050    class_name = mapped_class_name(porttype.name, @modulepath) 
    5151    defined_const = {} 
    52     result = MethodDefCreator.new(@definitions, @name_creator, @modulepath, defined_const).dump(porttype.name) 
    53     methoddef = result[:methoddef] 
     52    methoddef = MethodDefCreator.new(@definitions, @name_creator, @modulepath, defined_const).dump(porttype.name) 
    5453    wsdl_name = @definitions.name ? @definitions.name.name : 'default' 
    5554    mrname = safeconstname(wsdl_name + 'MappingRegistry') 
  • trunk/lib/wsdl/soap/driverCreator.rb

    r2003 r2007  
    6464    defined_const = {} 
    6565    mdcreator = MethodDefCreator.new(@definitions, @name_creator, @modulepath, defined_const) 
    66     result = mdcreator.dump(porttype) 
    67     methoddef = result[:methoddef] 
     66    methoddef = mdcreator.dump(porttype) 
    6867    binding = @definitions.bindings.find { |item| item.type == porttype } 
    6968    if binding.nil? or binding.soapbinding.nil? 
  • trunk/lib/wsdl/soap/methodDefCreator.rb

    r2005 r2007  
    3232    @complextypes = @definitions.collect_complextypes 
    3333    @elements = @definitions.collect_elements 
    34     @types = [] 
    35     @encoded = false 
    36     @literal = false 
    3734    @defined_const = defined_const 
    3835    @assigned_method = {} 
     
    4037 
    4138  def dump(name) 
    42     @types.clear 
    43     @encoded = false 
    44     @literal = false 
    4539    methoddef = "" 
    4640    porttype = @definitions.porttype(name) 
    4741    binding = porttype.find_binding 
    4842    if binding 
    49       binding.operations.each do |op_bind| 
    50         next unless op_bind # no binding is defined 
    51         next unless op_bind.soapoperation # not a SOAP operation binding 
     43      create(binding.name).each do |mdef| 
    5244        methoddef << ",\n" unless methoddef.empty? 
    53         methoddef << dump_method(op_bind).chomp 
     45        methoddef << dump_method(mdef).chomp 
    5446      end 
    5547    end 
    56     result = { 
    57       :methoddef => methoddef, 
    58       :types => @types, 
    59       :encoded => @encoded, 
    60       :literal => @literal 
    61     } 
    62     result 
     48    methoddef 
    6349  end 
     50 
     51  def create(bindingname) 
     52    binding = @definitions.binding(bindingname) 
     53    if binding 
     54      return binding.operations.collect { |op_bind| 
     55        next unless op_bind.soapoperation # not a SOAP operation binding 
     56        create_methoddef(op_bind) 
     57      } 
     58    end 
     59    nil 
     60  end 
     61 
     62private 
    6463 
    6564  def create_methoddef(op_bind) 
     
    6867    soapaction = op_info.boundid.soapaction 
    6968    qname = op_bind.soapoperation_name 
    70     style = op_info.style 
    71     inputuse = op_info.inputuse 
    72     outputuse = op_info.outputuse 
    7369    mdef = ::SOAP::RPC::MethodDef.new(name, soapaction, qname) 
    7470    op_info.parts.each do |part| 
    75       if style == :rpc 
    76         collect_type(part.type) 
     71      if op_info.style == :rpc 
    7772        mapped_class, qname = rpcdefinedtype(part) 
    7873      else 
     
    9186  end 
    9287 
    93 private 
    94  
    95   def dump_method(op_bind) 
    96     mdef = create_methoddef(op_bind) 
     88  def dump_method(mdef) 
    9789    style = mdef.style 
    9890    inputuse = mdef.inputuse 
     
    112104    :faults => #{mdef.faults.inspect} } 
    113105__EOD__ 
    114     if inputuse == :encoded or outputuse == :encoded 
    115       @encoded = true 
    116     end 
    117     if inputuse == :literal or outputuse == :literal 
    118       @literal = true 
    119     end 
    120106    if style == :rpc 
    121107      assign_const(mdef.qname.namespace, 'Ns') 
     
    184170  end 
    185171 
    186   def collect_type(type) 
    187     # ignore inline type definition. 
    188     return if type.nil? 
    189     return if @types.include?(type) 
    190     @types << type 
    191     return unless @complextypes[type] 
    192     collect_elements_type(@complextypes[type].elements) 
    193   end 
    194  
    195   def collect_elements_type(elements) 
    196     elements.each do |element| 
    197       case element 
    198       when WSDL::XMLSchema::Any 
    199         # nothing to do 
    200       when WSDL::XMLSchema::Element 
    201         collect_type(element.type) 
    202       when WSDL::XMLSchema::Sequence, WSDL::XMLSchema::Choice 
    203         collect_elements_type(element.elements) 
    204       else 
    205         raise RuntimeError.new("unknown type: #{element}") 
    206       end 
    207     end 
    208   end 
    209  
    210172  def param2str(params) 
    211173    params.collect { |param| 
  • trunk/lib/wsdl/soap/servletStubCreator.rb

    r1948 r2007  
    5050    class_name = mapped_class_name(porttype.name, @modulepath) 
    5151    defined_const = {} 
    52     result = MethodDefCreator.new(@definitions, @name_creator, @modulepath, defined_const).dump(porttype.name) 
    53     methoddef = result[:methoddef] 
    54  
     52    methoddef = MethodDefCreator.new(@definitions, @name_creator, @modulepath, defined_const).dump(porttype.name) 
    5553    wsdl_name = @definitions.name ? @definitions.name.name : 'default' 
    5654    mrname = safeconstname(wsdl_name + 'MappingRegistry') 
    57      
    5855    c1 = XSD::CodeGen::ClassDef.new(class_name) 
    5956    c1.def_require("soap/rpc/soaplet") 
  • trunk/lib/wsdl/soap/standaloneServerStubCreator.rb

    r1948 r2007  
    5151    class_name = mapped_class_name(porttype.name, @modulepath) 
    5252    defined_const = {} 
    53     result = MethodDefCreator.new(@definitions, @name_creator, @modulepath, defined_const).dump(porttype.name) 
    54     methoddef = result[:methoddef] 
    55  
     53    methoddef = MethodDefCreator.new(@definitions, @name_creator, @modulepath, defined_const).dump(porttype.name) 
    5654    wsdl_name = @definitions.name ? @definitions.name.name : 'default' 
    5755    mrname = safeconstname(wsdl_name + 'MappingRegistry') 
    58      
    5956    c1 = XSD::CodeGen::ClassDef.new(class_name) 
    6057    c1.def_require("soap/rpc/standaloneServer")