diff --git a/.credo.exs b/.credo.exs index 7180766..e6f1abb 100644 --- a/.credo.exs +++ b/.credo.exs @@ -101,7 +101,7 @@ {Credo.Check.Refactor.CyclomaticComplexity, []}, {Credo.Check.Refactor.FunctionArity, []}, {Credo.Check.Refactor.LongQuoteBlocks, []}, - {Credo.Check.Refactor.MapInto, []}, + {Credo.Check.Refactor.MapInto, false}, {Credo.Check.Refactor.MatchInCondition, []}, {Credo.Check.Refactor.NegatedConditionsInUnless, []}, {Credo.Check.Refactor.NegatedConditionsWithElse, []}, diff --git a/README.md b/README.md index a562237..fd37bcb 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,11 @@ # Soap -[![Build Status](https://travis-ci.org/potok-digital/soap.svg?branch=master)](https://travis-ci.org/potok-digital/soap) -[![Code coverage](https://img.shields.io/coveralls/github/potok-digital/soap.svg?style=flat)](https://coveralls.io/github/potok-digital/soap) +[![Build Status](https://travis-ci.org/elixir-soap/soap.svg?branch=master)](https://travis-ci.org/elixir-soap/soap) +[![Code coverage](https://img.shields.io/coveralls/github/elixir-soap/soap.svg?style=flat)](https://coveralls.io/github/elixir-soap/soap) +[![Hex version](https://img.shields.io/hexpm/v/soap.svg?style=flat)](https://hex.pm/packages/soap) +[![Hex license](https://img.shields.io/hexpm/l/soap.svg?style=flat)](https://hex.pm/packages/soap) +[![Hex downloads](https://img.shields.io/hexpm/dt/soap.svg?style=flat)](https://hex.pm/packages/soap) -Pure Elixir implementation of SOAP client - -## NOTE: Library is NOT production ready before 1.0 version +SOAP client for Elixir programming language ## Installation @@ -12,10 +13,10 @@ Pure Elixir implementation of SOAP client ```elixir def deps do - [{:soap, "~> 0.2.1"}] + [{:soap, "~> 0.2"}] end ``` -2) Add `soap` to the list of application dependencies +2) Add `soap` to the list of application dependencies(or just use extra_applications): ```elixir def application do @@ -23,25 +24,90 @@ def application do end ``` +## Configuration + +Configure version of SOAP protocol. Supported versions `1.1`(default) and `1.2`. +```elixir +config :soap, :globals, version: "1.1" +``` + ## Usage +The documentation is available on [HexDocs](https://hexdocs.pm/soap/api-reference.html). + +Parse WSDL file for execution of actions on its basis: +```elixir +iex(1)> {:ok, wsdl} = Soap.init_model(wsdl_path, :url) +{:ok, parsed_wsdl} +``` + +Get list of available operations: +```elixir +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: ```elixir wsdl_path = "http://www.dneonline.com/calculator.asmx?WSDL" action = "Add" params = %{intA: 1, intB: 2} -# Parse wsdl file for execution of action on its basis -{:ok, wsdl} = Soap.init_model(wsdl_path, :url) - -# Call action -{:ok, %Soap.Response{body: body, headers: headers, request_url: url, status_code: code}} = Soap.call(wsdl, action, params) - -# Parse body -Soap.Response.parse(body, code) +iex(3)> {:ok, response} = Soap.call(wsdl, action, params) +{:ok, + %Soap.Response{ + body: "3", + 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 + }} ``` -To add SOAP headers, pass in a `{headers, params}` tuple instead of just params. +Parse response: +```elixir +iex(4)> Soap.Response.parse(response) +%{AddResponse: %{AddResult: "3"}} +``` +To add SOAP headers, pass in a `{headers, params}` tuple instead of just params: ```elixir -%Soap.Response{} = Soap.call(wsdl, action, {%{Token: "foo"}, params}) +{:ok, %Soap.Response{}} = Soap.call(wsdl, action, {%{Token: "foo"}, params}) ``` + +## Contributing +We appreciate any contribution and open to [future requests](https://github.com/elixir-soap/soap/pulls). + +You can find a list of features and bugs in the [issue tracker](https://github.com/elixir-soap/soap/issues). + +## License + +Soap is released under the MIT license, see the [LICENSE](https://github.com/elixir-soap/soap/blob/master/LICENSE) file. diff --git a/docs/all.json b/docs/all.json index 737db3f..de961f7 100644 --- a/docs/all.json +++ b/docs/all.json @@ -1 +1 @@ -{"shell":true,"revision":"bf8273459d80eb756dc5f024535dea3fa3331f0f","objects":[{"type":null,"source":"lib/soap.ex:2","object_type":"ModuleObject","moduledoc":"Documentation for Soap.\n","module":"Elixir.Soap","id":"Soap"},{"type":"def","source":"lib/soap.ex:6","signature":[],"object_type":"FunctionObject","name":"hello","module_id":"Soap","id":"hello/0","doc":"Hello world.\n\n## Examples\n\n iex> Soap.hello\n :world\n\n","arity":0}],"language":"elixir","git_repo_url":"https://github.com/potok-digital/soap.git","client_version":"0.5.6","client_name":"inch_ex","branch_name":"master","args":[]} \ No newline at end of file +{"shell":true,"revision":"bf8273459d80eb756dc5f024535dea3fa3331f0f","objects":[{"type":null,"source":"lib/soap.ex:2","object_type":"ModuleObject","moduledoc":"Documentation for Soap.\n","module":"Elixir.Soap","id":"Soap"},{"type":"def","source":"lib/soap.ex:6","signature":[],"object_type":"FunctionObject","name":"hello","module_id":"Soap","id":"hello/0","doc":"Hello world.\n\n## Examples\n\n iex> Soap.hello\n :world\n\n","arity":0}],"language":"elixir","git_repo_url":"https://github.com/elixir-soap/soap.git","client_version":"0.5.6","client_name":"inch_ex","branch_name":"master","args":[]} diff --git a/lib/soap.ex b/lib/soap.ex index 697ebef..9a589c0 100644 --- a/lib/soap.ex +++ b/lib/soap.ex @@ -70,7 +70,7 @@ defmodule Soap do ## Parameters - `wsdl`: Wsdl model from `Soap.init_model/2` function. - - `action`: Soap action to be called. Use `Soap.operation/1` to get a list of available actions + - `action`: Soap action to be called. Use `Soap.operations/1` to get a list of available actions - `params`: Parameters to build the body of a SOAP request. - `headers`: Custom request headers. - `opts`: HTTPoison options. diff --git a/lib/soap/xsd.ex b/lib/soap/xsd.ex index 42f3bfd..8392065 100644 --- a/lib/soap/xsd.ex +++ b/lib/soap/xsd.ex @@ -1,7 +1,6 @@ defmodule Soap.Xsd do @moduledoc """ Provides functions for parsing xsd file - # TODO: Implement in version 0.2 """ import SweetXml, except: [parse: 1] diff --git a/mix.exs b/mix.exs index 7182fb2..c762789 100644 --- a/mix.exs +++ b/mix.exs @@ -11,7 +11,8 @@ defmodule Soap.MixProject do package: package(), description: description(), name: "Soap", - source_url: "https://github.com/potok-digital/soap", + source_url: "https://github.com/elixir-soap/soap", + docs: [main: "Soap", extras: ["README.md"]], test_coverage: [tool: ExCoveralls], preferred_cli_env: [ coveralls: :test, @@ -27,13 +28,13 @@ defmodule Soap.MixProject do files: ["lib", "mix.exs", "README.md", "LICENSE*"], maintainers: ["Petr Stepchenko", "Roman Kakorin"], licenses: ["MIT"], - links: %{"GitHub" => "https://github.com/potok-digital/soap"} + links: %{"GitHub" => "https://github.com/elixir-soap/soap"} ] end defp description do """ - Pure Elixir implementation of SOAP client + SOAP client for Elixir programming language """ end