Lather.Server (lather v1.0.42)

View Source

SOAP Server implementation for Lather.

Provides a framework for building SOAP web services in Elixir with:

  • Automatic WSDL generation from module definitions
  • Request/response handling and validation
  • Authentication and authorization support
  • Phoenix/Plug integration
  • Comprehensive error handling with SOAP faults

Usage

Define a SOAP service module:

defmodule MyApp.UserService do
  use Lather.Server

  @namespace "http://myapp.com/users"
  @service_name "UserService"

  @soap_operation %{
    name: "GetUser",
    input: [%{name: "userId", type: "string", required: true}],
    output: [%{name: "user", type: "User"}]
  }
  def get_user(%{"userId" => user_id}) do
    case fetch_user(user_id) do
      {:ok, user} -> {:ok, %{"user" => user}}
      {:error, :not_found} -> soap_fault("Client", "User not found")
    end
  end

  defp fetch_user(id), do: {:ok, %{"id" => id, "name" => "John Doe"}}
end

Then mount it in your Phoenix router or Plug application:

# In Phoenix router
scope "/soap" do
  pipe_through :api
  post "/users", Lather.Server.Plug, service: MyApp.UserService
end

# Or as a standalone Plug
plug Lather.Server.Plug, service: MyApp.UserService

Summary

Functions

Callback executed before module compilation to generate service metadata.

Macro for creating SOAP service modules.

Formats operation response according to SOAP conventions.

Validates parameter types according to operation definition.

Validates that required operation parameters are present.

Functions

__before_compile__(env)

(macro)

Callback executed before module compilation to generate service metadata.

__using__(opts \\ [])

(macro)

Macro for creating SOAP service modules.

format_response(result, operation)

Formats operation response according to SOAP conventions.

soap_fault(fault_code, fault_string, detail \\ nil)

Creates a SOAP fault response.

validate_param_types(params, operation)

Validates parameter types according to operation definition.

validate_required_params(params, operation)

Validates that required operation parameters are present.