Class: WSDL::Parser::Port Private

Inherits:
Object
  • Object
show all
Defined in:
lib/wsdl/parser/port.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 WSDL port element within a service.

A port defines a single endpoint for a service by associating a binding with a network address. It specifies where and how to communicate with the service using a particular protocol binding.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(port_node, soap_node) ⇒ Port

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 Port from WSDL port and SOAP address XML nodes.

Parameters:

  • port_node (Nokogiri::XML::Node)

    the wsdl:port element

  • soap_node (Nokogiri::XML::Node)

    the soap:address or soap12:address element



18
19
20
21
22
23
24
25
# File 'lib/wsdl/parser/port.rb', line 18

def initialize(port_node, soap_node)
  @port_node = port_node
  @name     = port_node['name']
  @binding  = port_node['binding']

  @type     = soap_node.namespace.href
  @location = soap_node['location']
end

Instance Attribute Details

#bindingString (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 qualified name of the binding this port uses.

Returns:

  • (String)

    the qualified name of the binding this port uses



31
32
33
# File 'lib/wsdl/parser/port.rb', line 31

def binding
  @binding
end

#locationString (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 endpoint URL for this port.

Returns:

  • (String)

    the endpoint URL for this port



37
38
39
# File 'lib/wsdl/parser/port.rb', line 37

def location
  @location
end

#nameString (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 name of this port.

Returns:

  • (String)

    the name of this port



28
29
30
# File 'lib/wsdl/parser/port.rb', line 28

def name
  @name
end

#typeString (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 SOAP namespace URI indicating the protocol version.

Returns:

  • (String)

    the SOAP namespace URI indicating the protocol version



34
35
36
# File 'lib/wsdl/parser/port.rb', line 34

def type
  @type
end

Instance Method Details

#fetch_binding(documents) ⇒ Binding

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.

Fetches the binding that this port references.

Parameters:

Returns:

Raises:



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

def fetch_binding(documents)
  binding_name = QName.parse(
    @binding,
    namespaces: @port_node.namespaces,
    default_namespace: QName.document_namespace(@port_node.document.root)
  )

  documents.bindings.fetch(binding_name) do
    raise UnresolvedReferenceError.new(
      "Unable to find binding #{binding_name} for port #{@name.inspect}",
      reference_type: :binding,
      reference_name: binding_name.to_s,
      context: "port #{@name.inspect}"
    )
  end
end

#to_hashHash

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.

Converts this port to a Hash representation.

Examples:

port.to_hash
# => { "PortName" => { type: "http://schemas.xmlsoap.org/wsdl/soap/",
#                      location: "http://example.com/service" } }

Returns:

  • (Hash)

    a hash with the port name as key and type/location as values



68
69
70
# File 'lib/wsdl/parser/port.rb', line 68

def to_hash
  { name => { type: type, location: location } }
end