Class: WSDL::Parser::Result Private

Inherits:
Object
  • Object
show all
Defined in:
lib/wsdl/parser/result.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 parsed WSDL document definition.

This class is responsible for importing and parsing WSDL documents, including all referenced schemas and imports. It provides access to services, ports, and operations defined in the WSDL.

This is the main result object produced by the parsing process and is used internally by Client to access WSDL information.

Examples:

Accessing services (URL-loaded, no file access)

result = Parser::Result.parse('http://example.com/service?wsdl', http)
result.services
# => {"ServiceName" => {ports: {"PortName" => {type: "...", location: "..."}}}}

Loading from file with sandbox

result = Parser::Result.parse('/app/wsdl/service.wsdl', http,
                              sandbox_paths: ['/app/wsdl'])

Getting operation names

operations = result.operations('ServiceName', 'PortName')
# => ["GetUser", "CreateUser", "DeleteUser"]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(documents:, schemas:, limits:, strict_schema:, schema_import_errors:) ⇒ Result

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 Result with pre-computed data.

This constructor performs no I/O. Use parse to import and parse a WSDL document from a URL or file path.

Parameters:

  • documents (DocumentCollection)

    the parsed document collection

  • schemas (Schema::Collection)

    the parsed schema collection

  • limits (Limits)

    the resource limits used during parsing

  • strict_schema (Boolean)

    whether strict schema mode was enabled

  • schema_import_errors (Array<SchemaImportError>)

    recoverable errors from import



74
75
76
77
78
79
80
# File 'lib/wsdl/parser/result.rb', line 74

def initialize(documents:, schemas:, limits:, strict_schema:, schema_import_errors:)
  @documents = documents
  @schemas = schemas
  @limits = limits
  @strict_schema = strict_schema
  @schema_import_errors = schema_import_errors
end

Instance Attribute Details

#documentsDocumentCollection (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.

The collection of parsed WSDL documents.

Returns:



85
86
87
# File 'lib/wsdl/parser/result.rb', line 85

def documents
  @documents
end

#limitsLimits (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.

The resource limits used for parsing.

Returns:

  • (Limits)

    the limits instance



95
96
97
# File 'lib/wsdl/parser/result.rb', line 95

def limits
  @limits
end

#schema_import_errorsArray<SchemaImportError> (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.

Recoverable schema import errors captured during import.

Returns:



105
106
107
# File 'lib/wsdl/parser/result.rb', line 105

def schema_import_errors
  @schema_import_errors
end

#schemasSchema::Collection (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.

The collection of XML schemas referenced by the WSDL.

Returns:



90
91
92
# File 'lib/wsdl/parser/result.rb', line 90

def schemas
  @schemas
end

#strict_schemaBoolean (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 whether strict schema mode is enabled.

Returns:

  • (Boolean)


100
101
102
# File 'lib/wsdl/parser/result.rb', line 100

def strict_schema
  @strict_schema
end

Class Method Details

.parse(wsdl, http, parse_options = nil) ⇒ Result

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.

Imports and parses a WSDL document, returning a fully-populated Result.

This factory method performs source validation, sandbox resolution, and the full import/parse cycle. Use #initialize directly only when you already have pre-computed results (e.g. in tests).

Parameters:

  • wsdl (String)

    a URL or local file path to the WSDL document

  • http (Object)

    an HTTP adapter instance for fetching remote documents

  • parse_options (ParseOptions) (defaults to: nil)

    parse configuration options. When omitted, WSDL::ParseOptions.default is used.

Returns:

  • (Result)

    the parsed result



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/wsdl/parser/result.rb', line 42

def self.parse(wsdl, http, parse_options = nil, **)
  parse_options ||= ParseOptions.default(**)

  documents = DocumentCollection.new
  schemas = Schema::Collection.new

  source = Source.validate_wsdl!(wsdl)
  resolved_sandbox_paths = source.resolve_sandbox_paths(parse_options.sandbox_paths)
  resolver = Resolver.new(http, sandbox_paths: resolved_sandbox_paths, limits: parse_options.limits)
  importer = Importer.new(resolver, documents, schemas, parse_options)
  importer.import(source.value)

  new(
    documents:,
    schemas:,
    limits: parse_options.limits,
    strict_schema: parse_options.strict_schema,
    schema_import_errors: importer.schema_import_errors.freeze
  )
end

Instance Method Details

#operation(service_name, port_name, operation_name) ⇒ OperationInfo

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 an OperationInfo for a given service, port, and operation name.

Parameters:

  • service_name (String)

    the name of the service

  • port_name (String)

    the name of the port

  • operation_name (String)

    the name of the operation

Returns:

Raises:

  • (ArgumentError)

    if the service, port, or operation does not exist



157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/wsdl/parser/result.rb', line 157

def operation(service_name, port_name, operation_name)
  verify_operation_exists!(service_name, port_name, operation_name)

  port = @documents.service_port(service_name, port_name)
  endpoint = port.location

  binding = port.fetch_binding(@documents)
  binding_operation = binding.operations.fetch(operation_name)

  port_type = binding.fetch_port_type(@documents)
  port_type_operation = port_type.operations.fetch(operation_name)

  OperationInfo.new(operation_name, endpoint, binding_operation, port_type_operation, self)
end

#operations(service_name, port_name) ⇒ Array<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 an array of operation names for a given service and port.

Parameters:

  • service_name (String)

    the name of the service

  • port_name (String)

    the name of the port

Returns:

  • (Array<String>)

    the list of operation names

Raises:

  • (ArgumentError)

    if the service or port does not exist



141
142
143
144
145
146
147
148
# File 'lib/wsdl/parser/result.rb', line 141

def operations(service_name, port_name)
  verify_service_and_port_exist!(service_name, port_name)

  port = @documents.service_port(service_name, port_name)
  binding = port.fetch_binding(@documents)

  binding.operations.keys
end

#schema_complete_for_operation?(operation_info) ⇒ Boolean

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 whether schema metadata is complete for the given operation.

In best-effort import mode, failures may be tolerated globally. This method allows operation-level gating for strict request validation.

Parameters:

Returns:

  • (Boolean)


179
180
181
182
183
184
185
186
187
188
189
# File 'lib/wsdl/parser/result.rb', line 179

def schema_complete_for_operation?(operation_info)
  return true if @schema_import_errors.empty?
  return true if input_empty?(operation_info)
  return false if @schema_import_errors.any? { |error| error.base_location.nil? }

  operation_namespaces = input_namespaces_for(operation_info)
  return true if operation_namespaces.empty?

  affected_namespaces = namespaces_affected_by_import_errors
  !operation_namespaces.intersect?(affected_namespaces)
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 primary service.

This is the name attribute of the root WSDL definitions element.

Returns:

  • (String)

    the service name



112
113
114
# File 'lib/wsdl/parser/result.rb', line 112

def service_name
  @documents.service_name
end

#servicesHash

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 a Hash of services and ports defined by the WSDL.

Examples:

result.services
# => {
#      "UserService" => {
#        ports: {
#          "UserServicePort" => {
#            type: "http://schemas.xmlsoap.org/wsdl/soap/",
#            location: "http://example.com/UserService"
#          }
#        }
#      }
#    }

Returns:

  • (Hash)

    a hash mapping service names to their port definitions



131
132
133
# File 'lib/wsdl/parser/result.rb', line 131

def services
  @documents.services.values.inject({}) { |memo, service| memo.merge service.to_hash }
end