Lather.DynamicClient (lather v1.0.42)

View Source

Dynamic SOAP client that can work with any SOAP service.

This client uses WSDL analysis to understand service operations and dynamically builds SOAP requests without requiring service-specific code.

Summary

Functions

Generates a report of the service capabilities.

Gets detailed information about a specific operation.

Gets service information including endpoints, namespaces, and types.

Lists all available operations for the service.

Creates a new dynamic client from a WSDL URL or file path.

Validates parameters for a specific operation without making the call.

Types

t()

@type t() :: %Lather.DynamicClient{
  base_client: Lather.Client.t(),
  default_options: keyword(),
  service_info: map()
}

Functions

call(dynamic_client, operation_name, parameters, options \\ [])

@spec call(t(), String.t(), map(), keyword()) :: {:ok, map()} | {:error, term()}

Calls a SOAP operation dynamically.

Parameters

  • client - The dynamic client
  • operation_name - Name of the operation to call
  • parameters - Map of parameters for the operation
  • options - Additional call options

Options

  • :headers - Additional SOAP headers
  • :timeout - Request timeout override
  • :validate - Whether to validate parameters (default: true)

Examples

{:ok, response} = Lather.DynamicClient.call(
  client,
  "GetUser",
  %{"userId" => "12345"}
)

{:ok, response} = Lather.DynamicClient.call(
  client,
  "CreateUser",
  %{"userData" => %{"name" => "John", "email" => "john@example.com"}},
  headers: [%{"Authentication" => "Bearer token123"}]
)

generate_service_report(dynamic_client)

@spec generate_service_report(t()) :: String.t()

Generates a report of the service capabilities.

Examples

report = Lather.DynamicClient.generate_service_report(client)
IO.puts(report)

get_operation_info(dynamic_client, operation_name)

@spec get_operation_info(t(), String.t()) ::
  {:ok, map()} | {:error, :operation_not_found}

Gets detailed information about a specific operation.

Parameters

  • client - The dynamic client
  • operation_name - Name of the operation to inspect

Examples

{:ok, operation_info} = Lather.DynamicClient.get_operation_info(client, "GetUser")
# %{
#   name: "GetUser",
#   required_parameters: ["userId"],
#   optional_parameters: [],
#   return_type: "User",
#   soap_action: "http://example.com/GetUser"
# }

get_service_info(dynamic_client)

@spec get_service_info(t()) :: map()

Gets service information including endpoints, namespaces, and types.

Examples

service_info = Lather.DynamicClient.get_service_info(client)
# %{
#   service_name: "MyService",
#   target_namespace: "http://example.com/service",
#   endpoints: [...],
#   operations: [...],
#   types: [...]
# }

list_operations(dynamic_client)

@spec list_operations(t()) :: [map()]

Lists all available operations for the service.

Examples

operations = Lather.DynamicClient.list_operations(client)
# [
#   %{name: "GetUser", required_parameters: ["userId"], ...},
#   %{name: "CreateUser", required_parameters: ["userData"], ...}
# ]

new(wsdl_source, options \\ [])

@spec new(
  String.t(),
  keyword()
) :: {:ok, t()} | {:error, term()}

Creates a new dynamic client from a WSDL URL or file path.

Parameters

  • wsdl_source - URL or file path to the WSDL
  • options - Client configuration options

Options

  • :service_name - Specific service name if WSDL contains multiple services
  • :endpoint_override - Override the endpoint URL from WSDL
  • :default_headers - Default headers to include in all requests
  • :authentication - Authentication configuration
  • :timeout - Default request timeout
  • :soap_version - SOAP protocol version (:v1_1 or :v1_2, auto-detected if not specified)

Examples

{:ok, client} = Lather.DynamicClient.new("http://example.com/service?wsdl")

{:ok, client} = Lather.DynamicClient.new(
  "http://example.com/service?wsdl",
  authentication: {:basic, "user", "pass"},
  timeout: 60_000
)

validate_parameters(dynamic_client, operation_name, parameters)

@spec validate_parameters(t(), String.t(), map()) :: :ok | {:error, term()}

Validates parameters for a specific operation without making the call.

Parameters

  • client - The dynamic client
  • operation_name - Name of the operation
  • parameters - Parameters to validate

Examples

:ok = Lather.DynamicClient.validate_parameters(client, "GetUser", %{"userId" => "123"})

{:error, {:missing_required_parameter, "userId"}} =
  Lather.DynamicClient.validate_parameters(client, "GetUser", %{})