Castile v1.0.0 Castile View Source

Documentation for Castile.

Link to this section Summary

Functions

Same as call/4, but raises an exception instead

Converts an operation’s parameters into XML

Initializes a service model from a WSDL file. This parses the WSDL and it’s imports recursively, building an internal model of all the XSD types and SOAP metadata for later use

Link to this section Functions

Link to this function call(model, operation, params \\ %{}, headers \\ [], opts \\ []) View Source
call(
  wsdl :: Castile.Model.t(),
  operation :: atom(),
  params :: map(),
  headers :: list() | map(),
  opts :: list()
) ::
  {:ok, term()}
  | {:error,
     %Castile.Fault{
       __exception__: term(),
       detail: term(),
       faultactor: term(),
       faultcode: term(),
       faultstring: term()
     }}
  | {:error, term()}

Calls a SOAP service operation.

Examples

iex> Castile.call(model, :CountryISOCode, %{sCountryName: "Netherlands"})
{:ok, "NL"}
Link to this function call!(model, operation, params \\ %{}, headers \\ []) View Source
call!(
  wsdl :: Castile.Model.t(),
  operation :: atom(),
  params :: map(),
  headers :: list() | map()
) :: {:ok, term()} | no_return()

Same as call/4, but raises an exception instead.

Link to this function cast_type(name, input, types) View Source
cast_type(name :: atom(), input :: map(), types :: term()) :: tuple()
Link to this function convert(model, type, params) View Source
convert(Castile.Model.t(), operation :: atom(), params :: map()) ::
  {:ok, binary()} | {:error, term()}

Converts an operation’s parameters into XML.

Examples

iex> Castile.call(model, :CountryISOCode, %{sCountryName: "Netherlands"})
{:ok, "<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><CountryISOCode xmlns="http://www.oorsprong.org/websamples.countryinfo"><sCountryName>Netherlands</sCountryName></CountryISOCode></soap:Body></soap:Envelope>"}
Link to this function init_model(wsdl_file, namespaces \\ []) View Source
init_model(Path.t(), namespaces :: list()) :: Castile.Model.t()

Initializes a service model from a WSDL file. This parses the WSDL and it’s imports recursively, building an internal model of all the XSD types and SOAP metadata for later use.

Similar to Elixir’s pre-compiled Regexes, it’s recommended to do this at compile-time in an @attribute.

Examples

iex> model = Castile.init_model("CountryInfoService.wsdl")
%Castile.Model{...}