# File lib/wsdl/soap/methodDefCreator.rb, line 23 23: def initialize(definitions, name_creator, modulepath, defined_const) 24: @definitions = definitions 25: @name_creator = name_creator 26: @modulepath = modulepath 27: @simpletypes = @definitions.collect_simpletypes 28: @complextypes = @definitions.collect_complextypes 29: @elements = @definitions.collect_elements 30: @types = [] 31: @encoded = false 32: @literal = false 33: @defined_const = defined_const 34: end
# File lib/wsdl/soap/methodDefCreator.rb, line 81 81: def collect_documentparameter(operation) 82: param = [] 83: operation.inputparts.each do |input| 84: param << param_set(::SOAP::RPC::SOAPMethod::IN, input.name, 85: documentdefinedtype(input)) 86: end 87: operation.outputparts.each do |output| 88: param << param_set(::SOAP::RPC::SOAPMethod::OUT, output.name, 89: documentdefinedtype(output)) 90: end 91: param 92: end
# File lib/wsdl/soap/methodDefCreator.rb, line 61 61: def collect_rpcparameter(operation) 62: result = operation.inputparts.collect { |part| 63: collect_type(part.type) 64: param_set(::SOAP::RPC::SOAPMethod::IN, part.name, rpcdefinedtype(part)) 65: } 66: outparts = operation.outputparts 67: if outparts.size > 0 68: retval = outparts[0] 69: collect_type(retval.type) 70: result << param_set(::SOAP::RPC::SOAPMethod::RETVAL, retval.name, 71: rpcdefinedtype(retval)) 72: cdr(outparts).each { |part| 73: collect_type(part.type) 74: result << param_set(::SOAP::RPC::SOAPMethod::OUT, part.name, 75: rpcdefinedtype(part)) 76: } 77: end 78: result 79: end
# File lib/wsdl/soap/methodDefCreator.rb, line 36 36: def dump(name) 37: @types.clear 38: @encoded = false 39: @literal = false 40: methoddef = "" 41: porttype = @definitions.porttype(name) 42: binding = porttype.find_binding 43: if binding 44: binding.operations.each do |op_bind| 45: next unless op_bind # no binding is defined 46: next unless op_bind.soapoperation # not a SOAP operation binding 47: op = op_bind.find_operation 48: methoddef << ",\n" unless methoddef.empty? 49: methoddef << dump_method(op, op_bind).chomp 50: end 51: end 52: result = { 53: :methoddef => methoddef, 54: :types => @types, 55: :encoded => @encoded, 56: :literal => @literal 57: } 58: result 59: end
# File lib/wsdl/soap/methodDefCreator.rb, line 254 254: def cdr(ary) 255: result = ary.dup 256: result.shift 257: result 258: end
# File lib/wsdl/soap/methodDefCreator.rb, line 211 211: def collect_elements_type(elements) 212: elements.each do |element| 213: case element 214: when WSDL::XMLSchema::Any 215: # nothing to do 216: when WSDL::XMLSchema::Element 217: collect_type(element.type) 218: when WSDL::XMLSchema::Sequence, WSDL::XMLSchema::Choice 219: collect_elements_type(element.elements) 220: else 221: raise RuntimeError.new("unknown type: #{element}") 222: end 223: end 224: end
# File lib/wsdl/soap/methodDefCreator.rb, line 202 202: def collect_type(type) 203: # ignore inline type definition. 204: return if type.nil? 205: return if @types.include?(type) 206: @types << type 207: return unless @complextypes[type] 208: collect_elements_type(@complextypes[type].elements) 209: end
# File lib/wsdl/soap/methodDefCreator.rb, line 180 180: def documentdefinedtype(part) 181: if mapped = basetype_mapped_class(part.type) 182: ['::' + mapped.name, nil, part.name] 183: elsif definedtype = @simpletypes[part.type] 184: if definedtype.base 185: ['::' + basetype_mapped_class(definedtype.base).name, nil, part.name] 186: else 187: raise RuntimeError.new("unsupported simpleType: #{definedtype}") 188: end 189: elsif definedtype = @elements[part.element] 190: ['::SOAP::SOAPElement', part.element.namespace, part.element.name] 191: elsif definedtype = @complextypes[part.type] 192: ['::SOAP::SOAPElement', part.type.namespace, part.type.name] 193: else 194: raise RuntimeError.new("part: #{part.name} cannot be resolved") 195: end 196: end
# File lib/wsdl/soap/methodDefCreator.rb, line 96 96: def dump_method(operation, binding) 97: op_faults = {} 98: binding.fault.each do |fault| 99: op_fault = {} 100: soapfault = fault.soapfault 101: next if soapfault.nil? 102: faultclass = mapped_class_name(fault.name, @modulepath) 103: op_fault[:ns] = fault.name.namespace 104: op_fault[:name] = fault.name.name 105: op_fault[:namespace] = soapfault.namespace 106: op_fault[:use] = soapfault.use || "literal" 107: op_fault[:encodingstyle] = soapfault.encodingstyle || "document" 108: op_faults[faultclass] = op_fault 109: end 110: 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 117: if style == :rpc 118: qname = binding.soapoperation_name 119: paramstr = param2str(collect_rpcparameter(operation)) 120: else 121: qname = nil 122: paramstr = param2str(collect_documentparameter(operation)) 123: end 124: if paramstr.empty? 125: paramstr = '[]' 126: else 127: paramstr = "[ " << paramstr.split(/\r?\n/).join("\n ") << " ]" 128: end 129: definitions = #{ndq(binding.soapaction)}, #{dq(name)}, #{paramstr}, { :request_style => #{nsym(style)}, :request_use => #{nsym(inputuse)}, :response_style => #{nsym(style)}, :response_use => #{nsym(outputuse)}, :faults => #{op_faults_str} } 130: if inputuse == :encoded or outputuse == :encoded 131: @encoded = true 132: end 133: if inputuse == :literal or outputuse == :literal 134: @literal = true 135: end 136: if style == :rpc 137: assign_const(qname.namespace, 'Ns') 138: return [ #{dqname(qname)}, #{definitions}] 139: else 140: return [ #{definitions}] 141: end 142: end
# File lib/wsdl/soap/methodDefCreator.rb, line 245 245: def ele2str(ele) 246: qualified = ele 247: if qualified 248: "true" 249: else 250: "false" 251: end 252: end
# File lib/wsdl/soap/methodDefCreator.rb, line 226 226: def param2str(params) 227: params.collect { |param| 228: io, name, type, ele = param 229: unless ele.nil? 230: "[#{dq(io)}, #{dq(name)}, #{type2str(type)}, #{ele2str(ele)}]" 231: else 232: "[#{dq(io)}, #{dq(name)}, #{type2str(type)}]" 233: end 234: }.join(",\n") 235: end
# File lib/wsdl/soap/methodDefCreator.rb, line 198 198: def param_set(io_type, name, type, ele = nil) 199: [io_type, name, type, ele] 200: end
# File lib/wsdl/soap/methodDefCreator.rb, line 156 156: def rpcdefinedtype(part) 157: if mapped = basetype_mapped_class(part.type) 158: ['::' + mapped.name] 159: elsif definedtype = @simpletypes[part.type] 160: [nil, definedtype.name.namespace, definedtype.name.name] 161: elsif definedtype = @elements[part.element] 162: [nil, part.element.namespace, part.element.name] 163: elsif definedtype = @complextypes[part.type] 164: case definedtype.compoundtype 165: when :TYPE_STRUCT, :TYPE_EMPTY, :TYPE_ARRAY, :TYPE_SIMPLE 166: type = mapped_class_name(part.type, @modulepath) 167: [type, part.type.namespace, part.type.name] 168: when :TYPE_MAP 169: [Hash.name, part.type.namespace, part.type.name] 170: else 171: raise NotImplementedError.new("must not reach here: #{definedtype.compoundtype}") 172: end 173: elsif part.type == XSD::AnyTypeName 174: [nil] 175: else 176: raise RuntimeError.new("part: #{part.name} cannot be resolved") 177: end 178: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.