From cfd9416fbf35376fb8f1cd991f88acef58df3197 Mon Sep 17 00:00:00 2001 From: Petr Stepchenko Date: Wed, 3 Apr 2019 12:18:57 +0300 Subject: [PATCH 1/2] Fix action namespace when empty complex types --- lib/soap/request/params.ex | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/soap/request/params.ex b/lib/soap/request/params.ex index 45bbac1..5c6066b 100644 --- a/lib/soap/request/params.ex +++ b/lib/soap/request/params.ex @@ -217,9 +217,15 @@ defmodule Soap.Request.Params do @spec get_action_with_namespace(wsdl :: map(), operation :: String.t()) :: String.t() defp get_action_with_namespace(wsdl, operation) do - wsdl[:complex_types] - |> Enum.find(fn x -> x[:name] == operation end) - |> handle_action_extractor_result(wsdl, operation) + case wsdl[:complex_types] do + [] -> + "" + + _ -> + wsdl[:complex_types] + |> Enum.find(fn x -> x[:name] == operation end) + |> handle_action_extractor_result(wsdl, operation) + end end @spec get_header_with_namespace(wsdl :: map(), operation :: String.t()) :: String.t() From 073617e97089d45b4e2bc381f2900f3871779a98 Mon Sep 17 00:00:00 2001 From: Petr Stepchenko Date: Fri, 24 Jan 2020 14:28:28 +0300 Subject: [PATCH 2/2] Add test for wsdl without complex types --- .../fixtures/wsdl/CyberSourceTransaction.wsdl | 38 +++++++++++++++++++ .../runTransactionRequest.xml | 1 + test/soap/request/params_test.exs | 8 ++++ 3 files changed, 47 insertions(+) create mode 100644 test/fixtures/wsdl/CyberSourceTransaction.wsdl create mode 100644 test/fixtures/xml/cyber_source_transaction/runTransactionRequest.xml diff --git a/test/fixtures/wsdl/CyberSourceTransaction.wsdl b/test/fixtures/wsdl/CyberSourceTransaction.wsdl new file mode 100644 index 0000000..b9e072e --- /dev/null +++ b/test/fixtures/wsdl/CyberSourceTransaction.wsdl @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CyberSource Web Service + + + + + \ No newline at end of file diff --git a/test/fixtures/xml/cyber_source_transaction/runTransactionRequest.xml b/test/fixtures/xml/cyber_source_transaction/runTransactionRequest.xml new file mode 100644 index 0000000..90e7b91 --- /dev/null +++ b/test/fixtures/xml/cyber_source_transaction/runTransactionRequest.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/soap/request/params_test.exs b/test/soap/request/params_test.exs index 69c797c..526f18a 100644 --- a/test/soap/request/params_test.exs +++ b/test/soap/request/params_test.exs @@ -53,4 +53,12 @@ defmodule Soap.Request.ParamsTest do "Element date has wrong format. Expects [0-9]{4}-[0-9]{2}-[0-9]{2} format." ] end + + test "#build_body without complex types" do + xml_body = Fixtures.load_xml("cyber_source_transaction/runTransactionRequest.xml") + {_, wsdl} = Wsdl.parse_from_file(Fixtures.get_file_path("wsdl/CyberSourceTransaction.wsdl")) + function_result = Params.build_body(wsdl, "runTransaction", %{}, nil) + + assert function_result == xml_body + end end