Soap v1.0.0 Soap View Source
The SOAP client for Elixir based on HTTPoison (for send requests) and SweetXml (for xml parsing). Soap contains 5 main modules:
Soap.Wsdl
- Build wsdl components data map. Can parse raw wsdl file from external url or local path. Wsdl which is prepared this module are using for send requests.Soap.Request
- Provides functionality for build and calling requests. Contains Request.Headers and Soap.Params submodules for build headers and build body with parameters validation respectively. This module is a wrapper over HTTPoison. It send requests and handle them.Soap.Response
- Handle soap response and handle them. It provides functionality for parsing xml-like body and transform it to comfortable structure. Structure for this module returns with necessary data after send a request.Soap.Xsd
- This module have same functionality as Soap.Wsdl module, but only for Xsd-files. It allows to parse xsd files from external resources or local path and convert it to map.Soap.Type
- Provides a functionality for find and parse complex types from raw xsd file. It uses in library for validation parameters when we build request body.
The Soap
module can be used to parse WSDL files:
iex> Soap.init_model("https://git.io/vNCWd", :url)
{:ok, %{
complex_types: [...],
endpoint: "...",
messages: [...],
namespaces: %{...},
operations: [...],
schema_attributes: %{...},
soap_version: "x.x",
validation_types: %{...}
}
}
And send requests: iex> Soap.call(wsdl, action, params) {:ok, %Soap.Response{}}
It's very common to use Soap in order to wrap APIs.
See call/5
for more details on how to issue requests to soap services
Link to this section Summary
Functions
Send a request to the SOAP server based on the passed WSDL file, action and parameters.
Returns {:ok, %Soap.Response{}}
if the request is successful, {:error, reason} otherwise
Initialization of a WSDL model. Response a map of parsed data from file.
Returns {:ok, wsdl}
Returns a list of available actions of the passed WSDL
Link to this section Functions
call(wsdl, operation, params, headers \\ [], opts \\ []) View Source
Send a request to the SOAP server based on the passed WSDL file, action and parameters.
Returns {:ok, %Soap.Response{}}
if the request is successful, {:error, reason} otherwise.
Parameters
wsdl
: Wsdl model fromSoap.init_model/2
function.action
: Soap action to be called. UseSoap.operations/1
to get a list of available actionsparams
: Parameters to build the body of a SOAP request.headers
: Custom request headers.opts
: HTTPoison options.
Examples
iex> Soap.call(wsdl, action, params)
{:ok, %Soap.Response{}}
init_model(path, type \\ :file) View Source
Initialization of a WSDL model. Response a map of parsed data from file.
Returns {:ok, wsdl}
.
Parameters
path
: Path for wsdl file.type
: Atom that represents the type of path for WSDL file. Can be:file
orurl
. Default::file
.
Examples
iex> {:ok, wsdl} = Soap.init_model("https://git.io/vNCWd", :url)
{:ok, %{...}}
operations(wsdl) View Source
Returns a list of available actions of the passed WSDL.
Parameters
wsdl
: Wsdl model fromSoap.init_model/2
function.
Examples
iex> {:ok, wsdl} = Soap.init_model("https://git.io/vNCWd", :url)
iex> Soap.operations(wsdl)
["SendMessage", "SendMessageMultipleRecipients"]