Class: WSDL::Parser::Document Private

Inherits:
Object
  • Object
show all
Defined in:
lib/wsdl/parser/document.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Represents a single parsed WSDL document.

Parses a WSDL XML document and provides access to its various sections including messages, bindings, port types, and services. Also extracts XML Schema definitions embedded within the WSDL.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document, schemas) ⇒ Document

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Creates a new Document by parsing a Nokogiri XML document.

Parameters:

  • document (Nokogiri::XML::Document)

    the parsed WSDL XML document

  • schemas (Schema::Collection)

    the schema collection for resolving types



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/wsdl/parser/document.rb', line 18

def initialize(document, schemas)
  @document = document
  @schemas = schemas

  reject_empty_document!
  reject_unsupported_version!

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

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

Instance Attribute Details

#bindingsHash{QName => Binding} (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the bindings defined in this document.

Returns:

  • (Hash{QName => Binding})

    the bindings defined in this document



45
46
47
# File 'lib/wsdl/parser/document.rb', line 45

def bindings
  @bindings
end

#messagesHash{QName => MessageInfo} (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the messages defined in this document.

Returns:



39
40
41
# File 'lib/wsdl/parser/document.rb', line 39

def messages
  @messages
end

#port_typesHash{QName => PortType} (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the port types defined in this document.

Returns:

  • (Hash{QName => PortType})

    the port types defined in this document



42
43
44
# File 'lib/wsdl/parser/document.rb', line 42

def port_types
  @port_types
end

#servicesHash{String => Service} (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the services defined in this document.

Returns:

  • (Hash{String => Service})

    the services defined in this document



48
49
50
# File 'lib/wsdl/parser/document.rb', line 48

def services
  @services
end

Instance Method Details

#importsArray<String>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the locations of imported WSDL documents.

Returns:

  • (Array<String>)

    the import locations



78
79
80
81
82
83
84
85
86
87
# File 'lib/wsdl/parser/document.rb', line 78

def imports
  imports = []

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

  imports
end

#schemas(source_location = nil) ⇒ Array<Schema::Definition>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the XML Schemas defined within this WSDL document.

Schemas are typically found within the wsdl:types element.

Parameters:

  • source_location (String, nil) (defaults to: nil)

    the location this document was loaded from, used for resolving relative imports/includes within the schemas

Returns:



71
72
73
# File 'lib/wsdl/parser/document.rb', line 71

def schemas(source_location = nil)
  schema_nodes.map { |node| Schema::Definition.new(node, @schemas, source_location) }
end

#service_nameString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the name of the WSDL definitions element.

Returns:

  • (String)

    the service name from the root element's name attribute



53
54
55
# File 'lib/wsdl/parser/document.rb', line 53

def service_name
  @document.root['name']
end

#target_namespaceString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the target namespace of this WSDL document.

Returns:

  • (String)

    the target namespace URI



60
61
62
# File 'lib/wsdl/parser/document.rb', line 60

def target_namespace
  @target_namespace ||= QName.document_namespace(@document.root)
end