class SOAP::WSDLDriverFactory

Attributes

wsdl[R]

Public Class Methods

new(wsdl) click to toggle source
# File lib/soap/wsdlDriver.rb, line 27
def initialize(wsdl)
  @wsdl = import(wsdl)
  @methoddefcreator = WSDL::SOAP::MethodDefCreator.new(@wsdl)
end

Public Instance Methods

createDriver(servicename = nil, portname = nil)

Backward compatibility.

Alias for: create_driver
create_driver(servicename = nil, portname = nil) click to toggle source

depricated old interface

# File lib/soap/wsdlDriver.rb, line 45
def create_driver(servicename = nil, portname = nil)
  warn("WSDLDriverFactory#create_driver is depricated.  Use create_rpc_driver instead.")
  port = find_port(servicename, portname)
  WSDLDriver.new(@wsdl, port, nil)
end
Also aliased as: createDriver
create_rpc_driver(servicename = nil, portname = nil) click to toggle source
# File lib/soap/wsdlDriver.rb, line 36
def create_rpc_driver(servicename = nil, portname = nil)
  port = find_port(servicename, portname)
  drv = SOAP::RPC::Driver.new(port.soap_address.location)
  init_driver(drv, port)
  add_operation(drv, port)
  drv
end
inspect() click to toggle source
# File lib/soap/wsdlDriver.rb, line 32
def inspect
  "#<#{self.class}:#{@wsdl.name}>"
end

Private Instance Methods

add_operation(drv, port) click to toggle source
# File lib/soap/wsdlDriver.rb, line 95
def add_operation(drv, port)
  port.find_binding.operations.each do |op_bind|
    op_name = op_bind.soapoperation_name
    soapaction = op_bind.soapaction || ''
    orgname = op_name.name
    name = XSD::CodeGen::GenSupport.safemethodname(orgname)
    param_def = create_param_def(op_bind)
    opt = {
      :request_style => op_bind.soapoperation_style,
      :response_style => op_bind.soapoperation_style,
      :request_use => op_bind.input.soapbody_use,
      :response_use => op_bind.output.soapbody_use,
      :elementformdefault => false,
      :attributeformdefault => false
    }
    if op_bind.soapoperation_style == :rpc
      drv.add_rpc_operation(op_name, soapaction, name, param_def, opt)
    else
      drv.add_document_operation(soapaction, name, param_def, opt)
    end
    if orgname != name and orgname.capitalize == name.capitalize
      ::SOAP::Mapping.define_singleton_method(drv, orgname) do |*arg|
        __send__(name, *arg)
      end
    end
  end
end
create_param_def(op_bind) click to toggle source
# File lib/soap/wsdlDriver.rb, line 127
def create_param_def(op_bind)
  op = op_bind.find_operation
  if op_bind.soapoperation_style == :rpc
    param_def = @methoddefcreator.collect_rpcparameter(op)
  else
    param_def = @methoddefcreator.collect_documentparameter(op)
  end
  # the first element of typedef in param_def is a String like
  # "::SOAP::SOAPStruct".  turn this String to a class.
  param_def.collect { |io, name, typedef|
    typedef[0] = Mapping.class_from_name(typedef[0])
    [io, name, typedef]
  }
end
filter_parts(partsdef, partssource) click to toggle source
# File lib/soap/wsdlDriver.rb, line 154
def filter_parts(partsdef, partssource)
  parts = partsdef.split(/\s+/)
  partssource.find_all { |part| parts.include?(part.name) }
end
find_port(servicename = nil, portname = nil) click to toggle source
# File lib/soap/wsdlDriver.rb, line 56
def find_port(servicename = nil, portname = nil)
  service = port = nil
  if servicename
    service = @wsdl.service(
      XSD::QName.new(@wsdl.targetnamespace, servicename))
  else
    service = @wsdl.services[0]
  end
  if service.nil?
    raise FactoryError.new("service #{servicename} not found in WSDL")
  end
  if portname
    port = service.ports[XSD::QName.new(@wsdl.targetnamespace, portname)]
    if port.nil?
      raise FactoryError.new("port #{portname} not found in WSDL")
    end
  else
    port = service.ports.find { |port| !port.soap_address.nil? }
    if port.nil?
      raise FactoryError.new("no ports have soap:address")
    end
  end
  if port.soap_address.nil?
    raise FactoryError.new("soap:address element not found in WSDL")
  end
  port
end
import(location) click to toggle source
# File lib/soap/wsdlDriver.rb, line 123
def import(location)
  WSDL::Importer.import(location)
end
init_driver(drv, port) click to toggle source
# File lib/soap/wsdlDriver.rb, line 84
def init_driver(drv, port)
  wsdl_elements = @wsdl.collect_elements
  wsdl_types = @wsdl.collect_complextypes + @wsdl.collect_simpletypes
  rpc_decode_typemap = wsdl_types +
    @wsdl.soap_rpc_complextypes(port.find_binding)
  drv.proxy.mapping_registry =
    Mapping::WSDLEncodedRegistry.new(rpc_decode_typemap)
  drv.proxy.literal_mapping_registry =
    Mapping::WSDLLiteralRegistry.new(wsdl_types, wsdl_elements)
end
param_def(type, name, klass, partqname) click to toggle source
# File lib/soap/wsdlDriver.rb, line 150
def param_def(type, name, klass, partqname)
  [type, name, [klass, partqname.namespace, partqname.name]]
end
partqname(part) click to toggle source
# File lib/soap/wsdlDriver.rb, line 142
def partqname(part)
  if part.type
    part.type
  else
    part.element
  end
end