Generic operation builder for SOAP services.
This module provides utilities to dynamically build SOAP requests for any operation defined in a WSDL, without requiring hardcoded service implementations.
Summary
Functions
Builds a SOAP request for any operation based on WSDL analysis.
Generates operation metadata for dynamic client usage.
Extracts response data from SOAP envelope based on operation output specification.
Validates parameters against operation input specification.
Functions
Builds a SOAP request for any operation based on WSDL analysis.
Parameters
operation_info- Operation information extracted from WSDL analysisparameters- Map of parameters for the operationoptions- Additional options for request building
Options
:style- SOAP style (:document or :rpc, default: :document):use- SOAP use (:literal or :encoded, default: :literal):namespace- Target namespace for the operation:headers- Additional SOAP headers:version- SOAP version (:v1_1or:v1_2, default::v1_1):namespace_prefix- Optional namespace prefix for the operation element (e.g."ns0"):types- Type definitions fromLather.Wsdl.Analyzer(service_info.types), used to pick the item element name for array-typed parts
Parameter values are serialised with Lather.Soap.Body.serialize_params/1:
nested maps become nested elements, lists become repeated sibling
elements, and DateTime/Date/Time/booleans are rendered as XML
schema literals. Parts whose WSDL type is an array (ArrayOf...,
xsd:string[]) wrap list values in the array's item element
(<part><item>..</item><item>..</item></part>), using the single
repeating element of the array type when :types is given and item
otherwise.
Examples
operation_info = %{
name: "GetUser",
input: %{
message: "GetUserRequest",
parts: [%{name: "userId", type: "xsd:string"}]
},
soap_action: "http://example.com/GetUser"
}
params = %{"userId" => "12345"}
{:ok, soap_envelope} = Lather.Operation.Builder.build_request(
operation_info,
params,
namespace: "http://example.com/service"
)
Generates operation metadata for dynamic client usage.
Parameters
operation_info- Operation information from WSDL
Examples
metadata = Lather.Operation.Builder.get_operation_metadata(operation_info)
# %{
# name: "GetUser",
# required_parameters: ["userId"],
# optional_parameters: [],
# return_type: "User",
# soap_action: "http://example.com/GetUser"
# }
Extracts response data from SOAP envelope based on operation output specification.
Parameters
operation_info- Operation information from WSDLresponse_envelope- Parsed SOAP response envelopeoptions- Parsing options
Examples
operation_info = %{
output: %{
parts: [%{name: "user", type: "tns:User"}]
}
}
{:ok, response_data} = Lather.Operation.Builder.parse_response(
operation_info,
parsed_response
)
Validates parameters against operation input specification.
Parameters
operation_info- Operation information from WSDLparameters- Parameters to validate
Examples
iex> operation_info = %{input: %{parts: [%{name: "userId", type: "xsd:string"}]}}
iex> Lather.Operation.Builder.validate_parameters(operation_info, %{"userId" => "123"})
:ok
iex> Lather.Operation.Builder.validate_parameters(operation_info, %{})
{:error, {:missing_required_parameter, "userId"}}