Pure Elixir implementation of SOAP client
- Add
soap
to your deps:
def deps do
[{:soap, "~> 0.2"}]
end
- Add
soap
to the list of application dependencies
def application do
[applications: [:logger, :soap]]
end
wsdl_path = "https://git.io/vNCWd"
action = "SendMessage"
params = %{recipient: "1", body: ""}
# Parse wsdl file for execution of action on its basis
{:ok, wsdl} = Soap.init_model(wsdl_path, :url)
# Call action
%Soap.Response{body: body, headers: headers, request_url: url, status_code: code} = Soap.call(wsdl, action, params)
# Parse body
Soap.Response.parse_body(body)
To add SOAP headers, pass in a {headers, params}
tuple instead of just params.
%Soap.Response{} = Soap.call(wsdl, action, {%{Token: "foo"}, params})