# File lib/soap/wsdlDriver.rb, line 31 31: def initialize(wsdl) 32: @wsdl = import(wsdl) 33: name_creator = WSDL::SOAP::ClassNameCreator.new 34: @modulepath = 'WSDLDriverFactory' 35: @methoddefcreator = 36: WSDL::SOAP::MethodDefCreator.new(@wsdl, name_creator, @modulepath, {}) 37: end
Backward compatibility.
deprecated old interface
# File lib/soap/wsdlDriver.rb, line 52 52: def create_driver(servicename = nil, portname = nil) 53: warn("WSDLDriverFactory#create_driver is deprecated. Use create_rpc_driver instead.") 54: port = find_port(servicename, portname) 55: WSDLDriver.new(@wsdl, port, nil) 56: end
# File lib/soap/wsdlDriver.rb, line 43 43: def create_rpc_driver(servicename = nil, portname = nil) 44: port = find_port(servicename, portname) 45: drv = SOAP::RPC::Driver.new(port.soap_address.location) 46: init_driver(drv, port) 47: add_operation(drv, port) 48: drv 49: end
# File lib/soap/wsdlDriver.rb, line 61 61: def dump_method_signatures(servicename = nil, portname = nil) 62: targetservice = XSD::QName.new(@wsdl.targetnamespace, servicename) if servicename 63: targetport = XSD::QName.new(@wsdl.targetnamespace, portname) if portname 64: sig = [] 65: element_definitions = @wsdl.collect_elements 66: @wsdl.services.each do |service| 67: next if targetservice and service.name != targetservice 68: service.ports.each do |port| 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") 73: end 74: end 75: sig.join("\n") 76: end
# File lib/soap/wsdlDriver.rb, line 119 119: def add_operation(drv, port) 120: port.find_binding.operations.each do |op_bind| 121: op_name = op_bind.soapoperation_name 122: soapaction = op_bind.soapaction || '' 123: orgname = op_name.name 124: name = XSD::CodeGen::GenSupport.safemethodname(orgname) 125: param_def = create_param_def(op_bind) 126: opt = { 127: :request_style => op_bind.soapoperation_style, 128: :response_style => op_bind.soapoperation_style, 129: :request_use => op_bind.soapbody_use_input, 130: :response_use => op_bind.soapbody_use_output 131: } 132: if op_bind.soapoperation_style == :rpc 133: drv.add_rpc_operation(op_name, soapaction, name, param_def, opt) 134: else 135: drv.add_document_operation(soapaction, name, param_def, opt) 136: end 137: if orgname != name and orgname.capitalize == name.capitalize 138: ::SOAP::Mapping.define_singleton_method(drv, orgname) do |*arg| 139: __send__(name, *arg) 140: end 141: end 142: end 143: end
# File lib/soap/wsdlDriver.rb, line 149 149: def create_param_def(op_bind) 150: op = op_bind.find_operation 151: if op_bind.soapoperation_style == :rpc 152: param_def = @methoddefcreator.collect_rpcparameter(op) 153: else 154: param_def = @methoddefcreator.collect_documentparameter(op) 155: end 156: # the first element of typedef in param_def is a String like 157: # "::SOAP::SOAPStruct". turn this String to a class. 158: param_def.collect { |io_type, name, param_type| 159: [io_type, name, ::SOAP::RPC::SOAPMethod.parse_param_type(param_type)] 160: } 161: end
# File lib/soap/wsdlDriver.rb, line 175 175: def filter_parts(partsdef, partssource) 176: parts = partsdef.split(/\s+/) 177: partssource.find_all { |part| parts.include?(part.name) } 178: end
# File lib/soap/wsdlDriver.rb, line 80 80: def find_port(servicename = nil, portname = nil) 81: service = port = nil 82: if servicename 83: service = @wsdl.service( 84: XSD::QName.new(@wsdl.targetnamespace, servicename)) 85: else 86: service = @wsdl.services[0] 87: end 88: if service.nil? 89: raise FactoryError.new("service #{servicename} not found in WSDL") 90: end 91: if portname 92: port = service.ports[XSD::QName.new(@wsdl.targetnamespace, portname)] 93: if port.nil? 94: raise FactoryError.new("port #{portname} not found in WSDL") 95: end 96: else 97: port = service.ports.find { |port| !port.soap_address.nil? } 98: if port.nil? 99: raise FactoryError.new("no ports have soap:address") 100: end 101: end 102: if port.soap_address.nil? 103: raise FactoryError.new("soap:address element not found in WSDL") 104: end 105: port 106: end
# File lib/soap/wsdlDriver.rb, line 145 145: def import(location) 146: WSDL::Importer.import(location) 147: end
# File lib/soap/wsdlDriver.rb, line 108 108: def init_driver(drv, port) 109: wsdl_elements = @wsdl.collect_elements 110: wsdl_types = @wsdl.collect_complextypes + @wsdl.collect_simpletypes 111: rpc_decode_typemap = wsdl_types + 112: @wsdl.soap_rpc_complextypes(port.find_binding) 113: drv.proxy.mapping_registry = 114: Mapping::WSDLEncodedRegistry.new(rpc_decode_typemap) 115: drv.proxy.literal_mapping_registry = 116: Mapping::WSDLLiteralRegistry.new(wsdl_types, wsdl_elements) 117: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.