class Sekken::WSDL::Document

Attributes

bindings[R]
messages[R]
port_types[R]
services[R]

Public Class Methods

new(document, schemas) click to toggle source
# File lib/sekken/wsdl/document.rb, line 11
def initialize(document, schemas)
  @document = document
  @schemas = schemas

  @messages, @bindings, @port_types, @services = {}, {}, {}, {}

  collect_sections(
    'message'  => { :collection => @messages,   :container => Message  },
    'binding'  => { :collection => @bindings,   :container => Binding  },
    'portType' => { :collection => @port_types, :container => PortType },
    'service'  => { :collection => @services,   :container => Service  }
  )
end

Public Instance Methods

imports() click to toggle source
# File lib/sekken/wsdl/document.rb, line 39
def imports
  imports = []

  @document.root.xpath('wsdl:import', 'wsdl' => Sekken::NS_WSDL).each do |node|
    location = node['location']
    imports << location if location
  end

  imports
end
schemas() click to toggle source
# File lib/sekken/wsdl/document.rb, line 35
def schemas
  schema_nodes.map { |node| XS::Schema.new(node, @schemas) }
end
service_name() click to toggle source
# File lib/sekken/wsdl/document.rb, line 27
def service_name
  @document.root['name']
end
target_namespace() click to toggle source
# File lib/sekken/wsdl/document.rb, line 31
def target_namespace
  @document.root['targetNamespace']
end

Private Instance Methods

collect_sections(mapping) click to toggle source
# File lib/sekken/wsdl/document.rb, line 52
def collect_sections(mapping)
  section_types = mapping.keys

  @document.root.element_children.each do |node|
    section_type = node.name
    next unless section_types.include? section_type

    node_name = node['name']
    type_mapping = mapping.fetch(section_type)

    collection = type_mapping[:collection]
    container = type_mapping[:container]

    collection[node_name] = container.new(node)
  end
end
schema_nodes() click to toggle source
# File lib/sekken/wsdl/document.rb, line 69
def schema_nodes
  @schema_nodes ||= schema_nodes! || []
end
schema_nodes!() click to toggle source
# File lib/sekken/wsdl/document.rb, line 73
def schema_nodes!
  root = @document.root
  return [root] if root.name == 'schema'

  types = root.at_xpath('wsdl:types', 'wsdl' => Sekken::NS_WSDL)
  types.element_children if types
end