Class: Wasabi::ServicePorts
- Inherits:
-
Object
- Object
- Wasabi::ServicePorts
- Defined in:
- lib/wasabi/service_ports.rb
Overview
Wasabi::ServicePorts
Parses the wsdl:service ports and wsdl:binding elements of a WSDL
document, so callers can resolve the SOAP endpoint of the port that
serves a given operation instead of always using the first port's
address.
Constant Summary collapse
- SOAP_1_1 =
"http://schemas.xmlsoap.org/wsdl/soap/"- SOAP_1_2 =
"http://schemas.xmlsoap.org/wsdl/soap12/"
Instance Method Summary collapse
-
#endpoint_for_operation(operation_name, soap_version: nil) ⇒ Object
Returns the SOAP endpoint (address) of the port serving the given SOAP operation.
-
#initialize(document) ⇒ ServicePorts
constructor
A new instance of ServicePorts.
-
#ports ⇒ Object
Returns the parsed service ports as an Array of Hashes with
:name,:binding(local binding name),:address(URI) and:soap_version(1, 2 or nil when the address is not a SOAP address) keys, in document order.
Constructor Details
#initialize(document) ⇒ ServicePorts
Returns a new instance of ServicePorts.
18 19 20 |
# File 'lib/wasabi/service_ports.rb', line 18 def initialize(document) @document = document end |
Instance Method Details
#endpoint_for_operation(operation_name, soap_version: nil) ⇒ Object
Returns the SOAP endpoint (address) of the port serving the given SOAP operation.
Walks operation -> portType -> binding -> port, so WSDLs exposing
several ports resolve to the address of the port that actually serves
the operation instead of the first port's address. When soap_version
is given, a port for that SOAP version is preferred, but the first
SOAP port for the operation is returned when no port matches the
requested version — routing degrades to the operation's best
available SOAP port instead of silently falling back to the WSDL's
first port. Non-SOAP ports (e.g. http:address) are never returned.
Returns nil when the operation has no SOAP ports at all, so
callers can fall back to the default endpoint.
43 44 45 46 |
# File 'lib/wasabi/service_ports.rb', line 43 def endpoint_for_operation(operation_name, soap_version: nil) port = preferred_port(operation_name, soap_version) port && port[:address] end |
#ports ⇒ Object
Returns the parsed service ports as an Array of Hashes with :name,
:binding (local binding name), :address (URI) and :soap_version
(1, 2 or nil when the address is not a SOAP address) keys, in
document order.
26 27 28 |
# File 'lib/wasabi/service_ports.rb', line 26 def ports @ports ||= parse_ports end |