Lyex icon indicating copy to clipboard operation
Lyex copied to clipboard

A modern SOAP client library for Elixir

This project is not usable for most WSDLs. It probably won't work for you. Please don't use in production!

Lyex

I've tried all the SOAP libraries for Elixir without success.

So Lyex was born.

I had to learn a ~~bit~~ lot about WSDL. I'm pretty sure this won't work on a bunch of WSDLs in the wild.

Much more to do.

Installation

If available in Hex, the package can be installed by adding lyex to your list of dependencies in mix.exs:

def deps do
  [
    {:lyex, "~> 0.1.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/lyex.

Usage

use the Lyex.Client with configuration to generate a full SOAP client with functions and structs.

defmodule KeefeClient do
  use Lyex.Client,
    service_name: "Keefe",
    wsdl: "https://services.keefegp.com/VendorPayment/VendorPaymentSvc.svc?wsdl",
    cache_dir: "./priv"
end


defmodule OtherModule do
  def run do

    response =
      KeefeClient.lookup_recipient(%Keefe.LookupRecipientInput{
        Auth: %{
          VendorCode: "redacted",
          UserId: "redacted",
          Password: "redacted"
        },
        RecipientNumber: "123456",
        FacilityCode: "ALDOC"
      })

    %Keefe.LookupRecipientOutput{
      DOBDay: "0",
      DOBMonth: "0",
      DOBYear: "0",
      FacilityName: nil,
      FirstName: nil,
      LastName: nil,
      MaxDepositAmount: "0",
      Result: %{Code: "INVALID_DEPOSITOR", Text: "Could not find resident"}
    } = response
  end
end

Features

  • [x] WSDL Parsing.
  • [x] Function generation for each operation.
  • [x] Input/output struct generation.
  • [x] parse responses into output structs.
  • [ ] generate documentation for functions/structs.
  • [ ] Input validation.
  • [ ] adding soap headers to requests.
  • [ ] supporting multiple ports.

Overview of code

  • Resolve file and cache it

  • Parse the WSDL file via SAX. When we hit an import, start at step 1 and store it into state.imports. Merge all imports into the main WSDL

  • Assemble the WSDL by resolving all messages, bindings, etc.

  • Generate code