Soap.Service (Soap v2.0.0)

View Source

A SOAP service, read from a WSDL.

Unlike Soap.Wsdl, this model follows the document's own links, from binding to port type to message to part to schema element, instead of guessing from names. It needs no application configuration, and bad input returns {:error, reason}.

{:ok, service} = Soap.Service.load("https://example.com/service?wsdl")
Soap.Service.operations(service)
#=> ["Add", "Subtract"]

{:ok, operation} = Soap.Service.operation(service, "Add", version: "1.2")
operation.soap_action
#=> "http://example.com/Add"

Options for load/2 and from_string/2

  • :import_root - a directory that local imports must stay inside.
  • :allow_imports_from - hosts that imports may be fetched from, or :all. See Soap.Service.Loader for the full rules.
  • :ignore_failed_imports - accept a partial model when an import can't be read. Otherwise that's an error.
  • :base - for from_string/2, the path or URL that relative imports resolve against.
  • :http - a Soap.HTTP implementation.
  • :http_opts - options passed to it.

Summary

Functions

The endpoint URL for an operation, or nil if no port serves its binding.

The endpoint URLs of every SOAP port.

Loads a service from a WSDL string.

Loads a service from a file path or an http or https URL.

Finds an operation by name.

The operation names the service offers.

The names of the service's SOAP ports.

Types

t()

@type t() :: %Soap.Service{
  operations: [Soap.Service.Operation.t()],
  ports: [Soap.Service.Port.t()],
  schema: Soap.Schema.t(),
  target_namespace: String.t() | nil,
  unresolved_imports: [{String.t(), atom()}]
}

Functions

endpoint(service, operation, port \\ nil)

@spec endpoint(t(), Soap.Service.Operation.t(), String.t() | nil) :: String.t() | nil

The endpoint URL for an operation, or nil if no port serves its binding.

With a port name, it's that port's address. Otherwise it's the first port's that serves the operation's binding.

endpoints(service)

@spec endpoints(t()) :: [String.t()]

The endpoint URLs of every SOAP port.

from_string(wsdl, opts \\ [])

@spec from_string(binary(), keyword()) :: {:ok, t()} | {:error, term()}

Loads a service from a WSDL string.

load(source, opts \\ [])

@spec load(String.t(), keyword()) :: {:ok, t()} | {:error, term()}

Loads a service from a file path or an http or https URL.

operation(service, name, opts \\ [])

@spec operation(t(), String.t(), keyword()) ::
  {:ok, Soap.Service.Operation.t()} | {:error, term()}

Finds an operation by name.

A service can offer an operation on several bindings. Without options, this returns the one on the first port, in document order, that offers it.

Options

  • :port - the name of a wsdl:port. Only its binding is used.
  • :version - the SOAP version, "1.1" or "1.2".
  • :input - the input's name, to choose between overloaded operations.

operations(service)

@spec operations(t()) :: [String.t()]

The operation names the service offers.

port_names(service)

@spec port_names(t()) :: [String.t()]

The names of the service's SOAP ports.