Changeset 2007
- Timestamp:
- 10/30/07 12:05:34 (1 year ago)
- Files:
-
- trunk/lib/soap/wsdlDriver.rb (modified) (4 diffs)
- trunk/lib/wsdl/soap/cgiStubCreator.rb (modified) (1 diff)
- trunk/lib/wsdl/soap/driverCreator.rb (modified) (1 diff)
- trunk/lib/wsdl/soap/methodDefCreator.rb (modified) (6 diffs)
- trunk/lib/wsdl/soap/servletStubCreator.rb (modified) (1 diff)
- trunk/lib/wsdl/soap/standaloneServerStubCreator.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/soap/wsdlDriver.rb
r2005 r2007 32 32 def initialize(wsdl) 33 33 @wsdl = import(wsdl) 34 name_creator = WSDL::SOAP::ClassNameCreator.new35 @modulepath = 'WSDLDriverFactory'36 @methoddefcreator =37 WSDL::SOAP::MethodDefCreator.new(@wsdl, name_creator, @modulepath, {})38 34 end 39 35 … … 45 41 port = find_port(servicename, portname) 46 42 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 49 47 drv 50 48 end … … 114 112 end 115 113 116 def init_driver(drv, port)114 def init_driver(drv, binding) 117 115 wsdl_elements = @wsdl.collect_elements 118 116 wsdl_types = @wsdl.collect_complextypes + @wsdl.collect_simpletypes 119 117 rpc_decode_typemap = wsdl_types + 120 @wsdl.soap_rpc_complextypes( port.find_binding)118 @wsdl.soap_rpc_complextypes(binding) 121 119 drv.proxy.mapping_registry = 122 120 Mapping::WSDLEncodedRegistry.new(rpc_decode_typemap) … … 125 123 end 126 124 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| 130 135 opt = { 131 136 :request_style => mdef.style, trunk/lib/wsdl/soap/cgiStubCreator.rb
r1948 r2007 50 50 class_name = mapped_class_name(porttype.name, @modulepath) 51 51 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) 54 53 wsdl_name = @definitions.name ? @definitions.name.name : 'default' 55 54 mrname = safeconstname(wsdl_name + 'MappingRegistry') trunk/lib/wsdl/soap/driverCreator.rb
r2003 r2007 64 64 defined_const = {} 65 65 mdcreator = MethodDefCreator.new(@definitions, @name_creator, @modulepath, defined_const) 66 result = mdcreator.dump(porttype) 67 methoddef = result[:methoddef] 66 methoddef = mdcreator.dump(porttype) 68 67 binding = @definitions.bindings.find { |item| item.type == porttype } 69 68 if binding.nil? or binding.soapbinding.nil? trunk/lib/wsdl/soap/methodDefCreator.rb
r2005 r2007 32 32 @complextypes = @definitions.collect_complextypes 33 33 @elements = @definitions.collect_elements 34 @types = []35 @encoded = false36 @literal = false37 34 @defined_const = defined_const 38 35 @assigned_method = {} … … 40 37 41 38 def dump(name) 42 @types.clear43 @encoded = false44 @literal = false45 39 methoddef = "" 46 40 porttype = @definitions.porttype(name) 47 41 binding = porttype.find_binding 48 42 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| 52 44 methoddef << ",\n" unless methoddef.empty? 53 methoddef << dump_method( op_bind).chomp45 methoddef << dump_method(mdef).chomp 54 46 end 55 47 end 56 result = { 57 :methoddef => methoddef, 58 :types => @types, 59 :encoded => @encoded, 60 :literal => @literal 61 } 62 result 48 methoddef 63 49 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 62 private 64 63 65 64 def create_methoddef(op_bind) … … 68 67 soapaction = op_info.boundid.soapaction 69 68 qname = op_bind.soapoperation_name 70 style = op_info.style71 inputuse = op_info.inputuse72 outputuse = op_info.outputuse73 69 mdef = ::SOAP::RPC::MethodDef.new(name, soapaction, qname) 74 70 op_info.parts.each do |part| 75 if style == :rpc 76 collect_type(part.type) 71 if op_info.style == :rpc 77 72 mapped_class, qname = rpcdefinedtype(part) 78 73 else … … 91 86 end 92 87 93 private 94 95 def dump_method(op_bind) 96 mdef = create_methoddef(op_bind) 88 def dump_method(mdef) 97 89 style = mdef.style 98 90 inputuse = mdef.inputuse … … 112 104 :faults => #{mdef.faults.inspect} } 113 105 __EOD__ 114 if inputuse == :encoded or outputuse == :encoded115 @encoded = true116 end117 if inputuse == :literal or outputuse == :literal118 @literal = true119 end120 106 if style == :rpc 121 107 assign_const(mdef.qname.namespace, 'Ns') … … 184 170 end 185 171 186 def collect_type(type)187 # ignore inline type definition.188 return if type.nil?189 return if @types.include?(type)190 @types << type191 return unless @complextypes[type]192 collect_elements_type(@complextypes[type].elements)193 end194 195 def collect_elements_type(elements)196 elements.each do |element|197 case element198 when WSDL::XMLSchema::Any199 # nothing to do200 when WSDL::XMLSchema::Element201 collect_type(element.type)202 when WSDL::XMLSchema::Sequence, WSDL::XMLSchema::Choice203 collect_elements_type(element.elements)204 else205 raise RuntimeError.new("unknown type: #{element}")206 end207 end208 end209 210 172 def param2str(params) 211 173 params.collect { |param| trunk/lib/wsdl/soap/servletStubCreator.rb
r1948 r2007 50 50 class_name = mapped_class_name(porttype.name, @modulepath) 51 51 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) 55 53 wsdl_name = @definitions.name ? @definitions.name.name : 'default' 56 54 mrname = safeconstname(wsdl_name + 'MappingRegistry') 57 58 55 c1 = XSD::CodeGen::ClassDef.new(class_name) 59 56 c1.def_require("soap/rpc/soaplet") trunk/lib/wsdl/soap/standaloneServerStubCreator.rb
r1948 r2007 51 51 class_name = mapped_class_name(porttype.name, @modulepath) 52 52 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) 56 54 wsdl_name = @definitions.name ? @definitions.name.name : 'default' 57 55 mrname = safeconstname(wsdl_name + 'MappingRegistry') 58 59 56 c1 = XSD::CodeGen::ClassDef.new(class_name) 60 57 c1.def_require("soap/rpc/standaloneServer")