Class: WSDL::Client
- Inherits:
-
Object
- Object
- WSDL::Client
- Defined in:
- lib/wsdl/client.rb
Overview
Main entry point for working with WSDL documents.
This class provides a high-level interface for parsing WSDL documents, inspecting services and operations, and executing SOAP requests.
Instance Attribute Summary collapse
-
#config ⇒ Config
readonly
Returns the behavioral configuration for this client.
Instance Method Summary collapse
-
#http ⇒ Object
Returns the HTTP adapter's config for customizing timeouts, SSL, etc.
-
#initialize(wsdl, http: nil, cache: nil, config: nil) ⇒ Client
constructor
Creates a new Client instance.
-
#operation(service_name_or_operation_name, port_name = nil, operation_name = nil) ⇒ Operation
Returns an Operation instance for calling a SOAP operation.
-
#operations(service_name = nil, port_name = nil) ⇒ Array<String>
Returns an array of operation names for a service and port.
-
#service_name ⇒ String?
Returns the name of the primary service defined by the WSDL.
-
#services ⇒ Hash
Returns the services and ports defined by the WSDL.
Constructor Details
#initialize(wsdl, http: nil, cache: nil, config: nil) ⇒ Client
Creates a new Client instance.
Behavioral options (format_xml, strict_schema, sandbox_paths,
limits) can be passed as keyword arguments or
grouped into a WSDL::Config object via the config: parameter.
When both are provided, keyword arguments take precedence.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/wsdl/client.rb', line 61 def initialize(wsdl, http: nil, cache: nil, config: nil, **) @config = config ? config.with(**) : Config.new(**) source = Source.validate_wsdl!(wsdl) @http = http || WSDL.http_adapter.new validate_http_adapter!(@http) resolved_sandbox_paths = source.resolve_sandbox_paths(@config.sandbox_paths) @parser_result = Parser::CachedResult.load( wsdl:, http: @http, cache:, parse_options: ParseOptions.new( sandbox_paths: resolved_sandbox_paths, limits: @config.limits, strict_schema: @config.strict_schema ) ) end |
Instance Attribute Details
#config ⇒ Config (readonly)
Returns the behavioral configuration for this client.
86 87 88 |
# File 'lib/wsdl/client.rb', line 86 def config @config end |
Instance Method Details
#http ⇒ Object
Returns the HTTP adapter's config for customizing timeouts, SSL, etc.
92 93 94 |
# File 'lib/wsdl/client.rb', line 92 def http @http.config end |
#operation(service_name, port_name, operation_name) ⇒ Operation #operation(operation_name) ⇒ Operation
Returns an Operation instance for calling a SOAP operation.
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/wsdl/client.rb', line 163 def operation(service_name_or_operation_name, port_name = nil, operation_name = nil) if port_name && !operation_name raise ArgumentError, 'Pass 1 argument (operation_name) or 3 arguments (service_name, port_name, operation_name).' end if operation_name service_name = service_name_or_operation_name else operation_name = service_name_or_operation_name service_name, port_name = resolve_service_and_port(nil, nil) end operation_info = @parser_result.operation(service_name.to_s, port_name.to_s, operation_name.to_s) verify_operation_style!(operation_info) Operation.new( operation_info, @parser_result, @http, config: @config ) end |
#operations(service_name, port_name) ⇒ Array<String> #operations ⇒ Array<String>
Returns an array of operation names for a service and port.
136 137 138 139 140 141 142 143 |
# File 'lib/wsdl/client.rb', line 136 def operations(service_name = nil, port_name = nil) if service_name && !port_name raise ArgumentError, 'Pass 0 arguments (auto-resolve) or 2 arguments (service_name, port_name).' end service_name, port_name = resolve_service_and_port(service_name, port_name) @parser_result.operations(service_name.to_s, port_name.to_s) end |
#service_name ⇒ String?
Returns the name of the primary service defined by the WSDL.
Falls back to the first discovered service key when the root
definitions element does not provide a name attribute.
114 115 116 117 118 119 |
# File 'lib/wsdl/client.rb', line 114 def service_name name = @parser_result.service_name return name if name && !name.empty? @parser_result.services.keys.first end |
#services ⇒ Hash
Returns the services and ports defined by the WSDL.
104 105 106 |
# File 'lib/wsdl/client.rb', line 104 def services @parser_result.services end |