Changeset 2001
- Timestamp:
- 10/14/07 09:34:27 (1 year ago)
- Files:
-
- branches/1_5/lib/soap/wsdlDriver.rb (modified) (2 diffs)
- branches/1_5/lib/wsdl/operationBinding.rb (modified) (2 diffs)
- branches/1_5/lib/wsdl/soap/classDefCreatorSupport.rb (modified) (2 diffs)
- branches/1_5/lib/wsdl/soap/clientSkeltonCreator.rb (modified) (2 diffs)
- branches/1_5/lib/wsdl/soap/driverCreator.rb (modified) (1 diff)
- branches/1_5/lib/wsdl/soap/methodDefCreator.rb (modified) (6 diffs)
- branches/1_5/lib/wsdl/soap/servantSkeltonCreator.rb (modified) (2 diffs)
- branches/1_5/test/wsdl/overload/expectedClient.rb (added)
- branches/1_5/test/wsdl/overload/expectedDriver.rb (added)
- branches/1_5/test/wsdl/overload/expectedServant.rb (added)
- branches/1_5/test/wsdl/overload/overload.wsdl (modified) (2 diffs)
- branches/1_5/test/wsdl/overload/test_overload.rb (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1_5/lib/soap/wsdlDriver.rb
r1975 r2001 68 68 service.ports.each do |port| 69 69 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 73 82 end 74 83 end … … 77 86 78 87 private 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 79 96 80 97 def find_port(servicename = nil, portname = nil) branches/1_5/lib/wsdl/operationBinding.rb
r1824 r2001 20 20 attr_reader :soapoperation 21 21 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 22 44 def initialize 23 45 super … … 35 57 def porttype 36 58 root.porttype(parent.type) 59 end 60 61 def boundid 62 BoundId.new(name, soapaction) 37 63 end 38 64 branches/1_5/lib/wsdl/soap/classDefCreatorSupport.rb
r1954 r2001 34 34 end 35 35 36 def dump_method_signature( operation, element_definitions)37 name = operation.name36 def dump_method_signature(name, operation, element_definitions) 37 methodname = safemethodname(name) 38 38 input = operation.input 39 39 output = operation.output 40 40 fault = operation.fault 41 signature = "#{ name }#{ dump_inputparam(input)}"41 signature = "#{methodname}#{dump_inputparam(input)}" 42 42 str = <<__EOD__ 43 43 # SYNOPSIS 44 # #{ name}#{dump_inputparam(input)}44 # #{methodname}#{dump_inputparam(input)} 45 45 # 46 46 # ARGS … … 224 224 raise RuntimeError.new("cannot define name of #{attribute}") 225 225 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 226 236 end 227 237 branches/1_5/lib/wsdl/soap/clientSkeltonCreator.rb
r1948 r2001 52 52 53 53 def dump_porttype(porttype) 54 assigned_method = collect_assigned_method(@definitions, porttype.name, @modulepath) 54 55 drv_name = mapped_class_basename(porttype.name, @modulepath) 55 56 … … 64 65 __EOD__ 65 66 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 70 80 end 71 81 result 72 82 end 73 83 74 def dump_operation(operation) 75 name = operation.name 84 def dump_operation(name, operation) 76 85 input = operation.input 77 86 "puts obj.#{ safemethodname(name) }#{ dump_inputparam(input) }" branches/1_5/lib/wsdl/soap/driverCreator.rb
r1948 r2001 63 63 class_name = mapped_class_basename(qname, @modulepath) 64 64 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) 66 67 methoddef = result[:methoddef] 67 68 binding = @definitions.bindings.find { |item| item.type == porttype } 68 69 if binding.nil? or binding.soapbinding.nil? 69 # not b ind or not a SOAP binding70 # not bound or not a SOAP binding 70 71 return '' 71 72 end branches/1_5/lib/wsdl/soap/methodDefCreator.rb
r1983 r2001 20 20 21 21 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 22 25 23 26 def initialize(definitions, name_creator, modulepath, defined_const) … … 32 35 @literal = false 33 36 @defined_const = defined_const 37 @assigned_method = {} 34 38 end 35 39 … … 94 98 private 95 99 96 def dump_method(operation, binding)100 def dump_method(operation, op_bind) 97 101 op_faults = {} 98 binding.fault.each do |fault|102 op_bind.fault.each do |fault| 99 103 op_fault = {} 100 104 soapfault = fault.soapfault … … 109 113 end 110 114 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 117 119 if style == :rpc 118 qname = binding.soapoperation_name120 qname = op_bind.soapoperation_name 119 121 paramstr = param2str(collect_rpcparameter(operation)) 120 122 else … … 128 130 end 129 131 definitions = <<__EOD__ 130 #{ndq( binding.soapaction)},132 #{ndq(op_bind.soapaction)}, 131 133 #{dq(name)}, 132 134 #{paramstr}, … … 152 154 __EOD__ 153 155 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 154 167 end 155 168 branches/1_5/lib/wsdl/soap/servantSkeltonCreator.rb
r1948 r2001 36 36 end 37 37 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) 40 40 result << "\n" 41 41 end … … 53 53 private 54 54 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) 57 58 c = XSD::CodeGen::ClassDef.new(class_name) 58 59 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 70 67 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 73 82 end 74 83 c.dump branches/1_5/test/wsdl/overload/overload.wsdl
r1701 r2001 1 1 <?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"> 3 3 <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"> 5 5 <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"/>8 6 <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/> 9 7 </schema> … … 29 27 </wsdl:message> 30 28 31 32 <wsdl:portType name="ConfluenceSoapService"> 29 <wsdl:portType name="OverloadServicePortType"> 33 30 <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"/> 36 33 </wsdl:operation> 37 34 38 35 <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"/> 41 38 </wsdl:operation> 42 43 39 </wsdl:portType> 44 40 45 <wsdl:binding name=" confluencesoapservice-v1SoapBinding" type="impl:ConfluenceSoapService">41 <wsdl:binding name="OverloadServiceSoap" type="tns:OverloadServicePortType"> 46 42 <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> 47 43 <wsdl:operation name="methodAlpha"> 48 44 <wsdlsoap:operation soapAction="methodAlpha1"/> 49 50 45 <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"/> 52 47 </wsdl:input> 53 54 48 <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"/> 56 50 </wsdl:output> 57 58 51 </wsdl:operation> 59 52 60 53 <wsdl:operation name="methodAlpha"> 61 54 <wsdlsoap:operation soapAction="methodAlpha2"/> 62 63 55 <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"/> 65 57 </wsdl:input> 66 67 58 <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"/> 69 60 </wsdl:output> 70 71 61 </wsdl:operation> 72 62 </wsdl:binding> 73 63 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/"/> 77 67 </wsdl:port> 78 68 </wsdl:service> branches/1_5/test/wsdl/overload/test_overload.rb
r1963 r2001 11 11 12 12 class TestOverload < Test::Unit::TestCase 13 TNS = " http://confluence.atlassian.com/rpc/soap-axis/confluenceservice-v1"13 TNS = "urn:overload" 14 14 15 15 Methods = [ … … 57 57 def teardown 58 58 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 60 66 @client.reset_stream if @client 61 67 end … … 73 79 gen.logger.level = Logger::FATAL 74 80 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 75 85 gen.opt['force'] = true 76 86 gen.run … … 86 96 def pathname(filename) 87 97 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") 88 104 end 89 105 … … 106 122 assert_equal(2, @client.call("methodAlpha2", "1", "2")) 107 123 end 124 125 def compare(expected, actual) 126 TestUtil.filecompare(pathname(expected), pathname(actual)) 127 end 108 128 end 109 129