Lather.Soap.Body (lather v1.0.42)

View Source

SOAP body utilities.

Provides functionality for creating and managing SOAP body content, including parameter serialization and response parsing.

Summary

Functions

Creates a SOAP body element for the given operation and parameters.

Serializes Elixir data structures to XML-compatible format.

Validates parameters against expected types and constraints.

Functions

create(operation, params, options \\ [])

@spec create(atom() | String.t(), map(), keyword()) :: map()

Creates a SOAP body element for the given operation and parameters.

Parameters

  • operation - Operation name (atom or string)
  • params - Operation parameters (map)
  • options - Body options

Options

  • :namespace - Target namespace for the operation
  • :namespace_prefix - Prefix for the target namespace

Examples

iex> Body.create(:get_user, %{id: 123}, namespace: "http://example.com")
%{
  "get_user" => %{
    "@xmlns" => "http://example.com",
    "id" => 123
  }
}

serialize_params(params)

@spec serialize_params(any()) :: any()

Serializes Elixir data structures to XML-compatible format.

Handles various Elixir types and converts them to XML-safe representations.

validate_params(params, schema)

@spec validate_params(map(), map()) :: :ok | {:error, [String.t()]}

Validates parameters against expected types and constraints.

Parameters

  • params - Parameters to validate
  • schema - Validation schema (map)

Schema Format

The schema is a map where keys are parameter names and values are validation rules:

%{
  "id" => [:required, :integer],
  "name" => [:required, :string, {:max_length, 50}],
  "email" => [:optional, :string, :email]
}