Soap.Decoder (Soap v2.0.0)

View Source

Turns a SOAP reply into plain Elixir data.

The result

The result is a map of the SOAP Body's children, by local name:

%{"AddResponse" => %{"AddResult" => 5}}

Keys are always strings, so a reply can't create atoms. Namespace prefixes are dropped, so a server changing its prefix changes nothing. Where a schema is available:

  • An element that can repeat is always a list, even with one item.
  • Values take their schema type: integers, floats, booleans, Date, DateTime, NaiveDateTime and Time. Base64 and hex decode to bytes. xsd:decimal stays a string, so no precision is lost. A value that doesn't parse stays a string.
  • xsi:nil is nil.

Attributes appear as "@name", and an element's text next to attributes as "#text". This is the same form Soap.Encoder accepts. When xsi:type says a value is a subtype of its declared type, "@xsi:type" holds that subtype's local name, which is also how Soap.Encoder takes it.

With no schema, an element repeated in the reply is a list and a single one isn't, and all values are strings.

Errors

A SOAP Fault is {:error, %Soap.Fault{}}, at any HTTP status. Anything else that isn't a usable reply is {:error, %Soap.Error{}}.

Summary

Functions

The reply size limit in opts, or the default of 100 MB.

Functions

decode(service, operation, status, headers, body, opts \\ [])

@spec decode(
  Soap.Service.t() | nil,
  Soap.Service.Operation.t() | nil,
  pos_integer(),
  list(),
  binary(),
  keyword()
) :: {:ok, Soap.Decoder.Decoded.t()} | {:error, Soap.Fault.t() | Soap.Error.t()}

Decodes an HTTP response.

service and operation can be nil. Replies then decode without a schema.

Options

  • :max_reply_size - the largest reply to accept, in bytes, both as received and once decompressed. Defaults to 100 MB. :infinity turns it off. A larger reply returns {:error, %Soap.Error{reason: :reply_too_large}}.

max_reply_size(opts)

@spec max_reply_size(keyword()) :: pos_integer() | :infinity

The reply size limit in opts, or the default of 100 MB.