Castile is a modern Elixir SOAP API client. It borrows ideas heavily from Detergent/yaws.
Why write another SOAP client? We really wanted to use Detergent/Detergentex, but ran into some issues (and also wanted to use HTTPoison as the HTTP client).
Detergent itself hasn't really been updated since 2013 (a time when erlang itself had no maps even), and Detergentex being just a lightweight wrapper around it, has the same shortcomings (even worse, the detergent version on hex.pm that detergentex relies on has no support for HTTPS). Erlsom has also been updated in the mean time, improving XML write speed and adding support for binaries natively.
Castile is an attempt at a fresh start, with a small API that's easy to use in Elixir.
At the moment, the supported subset is SOAP 1.1 with WSDL 1.1 (and document/literal format). SOAP 1.2 and WSDL 2.0 are on the roadmap, but none of the APIs we interact with use either of those, so I'm having problems finding a public API to test against (if you find one, please open an issue!).
Install from Hex.pm:
def deps do
[
{:castile, "~> 1.0"}
]
end
Docs can be found at https://hexdocs.pm/castile.
# It's recommended to do init_model at compile time, as an @attr
@model = Castile.init_model("CountryInfoService.wsdl")
# we take maps as input and return binaries
{:ok, resp} = Castile.call(@model, :CountryISOCode, %{sCountryName: "Netherlands"})
# "NL"
# More complex results get cast into maps:
model = Castile.init_model("BLZService.wsdl")
{:ok, resp} = Castile.call(model, :getBank, %{blz: "70070010"})
# resp => %{
# bezeichnung: "Deutsche Bank",
# bic: "DEUTDEMMXXX",
# ort: "München",
# plz: "80271"
# }
- Faults (1.1)
- HTTP client as adapter (specify module)
- SOAP 1.2 support
- RPC/encoding RPC/literal style (multiple bodies)
- WSDL 2.0 support
- Attachments/multipart
- detergent/yaws for the original SOAP implementation.
- bet365/soap for some of the ideas/fixes (simplifying the WSDL XSDs, already_imported schema patch)