Giter Site home page Giter Site logo

soap's Introduction

Soap

Build Status Code coverage Hex version Hex license Hex downloads

SOAP client for Elixir programming language

Installation

  1. Add soap to your deps:
def deps do
  [{:soap, "~> 1.0"}]
end
  1. Add soap to the list of application dependencies(or just use extra_applications):
def application do
  [applications: [:logger, :soap]]
end

Configuration

Configure version of SOAP protocol. Supported versions 1.1(default) and 1.2.

config :soap, :globals, version: "1.1"

Usage

The documentation is available on HexDocs.

Parse WSDL file for execution of actions on its basis:

iex(1)> {:ok, wsdl} = Soap.init_model(wsdl_path, :url)
{:ok, parsed_wsdl}

Get list of available operations:

iex(2)> Soap.operations(wsdl)
[
  %{
    input: %{body: nil, header: nil},
    name: "Add",
    soap_action: "http://tempuri.org/Add"
  },
  %{
    input: %{body: nil, header: nil},
    name: "Subtract",
    soap_action: "http://tempuri.org/Subtract"
  },
  %{
    input: %{body: nil, header: nil},
    name: "Multiply",
    soap_action: "http://tempuri.org/Multiply"
  },
  %{
    input: %{body: nil, header: nil},
    name: "Divide",
    soap_action: "http://tempuri.org/Divide"
  }
]

Call action:

wsdl_path = "http://www.dneonline.com/calculator.asmx?WSDL"
action = "Add"
params = %{intA: 1, intB: 2}

iex(3)> {:ok, response} = Soap.call(wsdl, action, params)
{:ok,
 %Soap.Response{
   body: "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><AddResponse xmlns=\"http://tempuri.org/\"><AddResult>3</AddResult></AddResponse></soap:Body></soap:Envelope>",
   headers: [
     {"Cache-Control", "private, max-age=0"},
     {"Content-Length", "325"},
     {"Content-Type", "text/xml; charset=utf-8"},
     {"Server", "Microsoft-IIS/7.5"},
     {"X-AspNet-Version", "2.0.50727"},
     {"X-Powered-By", "ASP.NET"},
     {"Date", "Thu, 14 Feb 2019 07:52:04 GMT"}
   ],
   request_url: "http://www.dneonline.com/calculator.asmx",
   status_code: 200
 }}

Parse response:

iex(4)> Soap.Response.parse(response)
%{AddResponse: %{AddResult: "3"}}

To add SOAP headers, pass in a {headers, params} tuple instead of just params:

{:ok, %Soap.Response{}} = Soap.call(wsdl, action, {%{Token: "foo"}, params})

Contributing

We appreciate any contribution and open to future requests.

You can find a list of features and bugs in the issue tracker.

License

Soap is released under the MIT license, see the LICENSE file.

soap's People

Contributors

sigmen avatar nitrino avatar astorre88 avatar spieker avatar shahryarjb avatar kelcecil avatar pjullrich avatar retgoat avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.