Error (Protocol.UndefinedError)
Closed this issue · 1 comments
shahryarjb commented
Hello, please use this WSDL link http://banktest.ir/gateway/saman/Payments/InitPayment?wsdl
elixir: v1.8.0 , {:soap, "~> 1.0.1"}
when I use it like this:
defmodule Khatoghalam.Extera.Bank.Saman do
def get_saman_token do
wsdl_url = "http://banktest.ir/gateway/saman/Payments/InitPayment?wsdl"
with {:ok, wsdl} <- Soap.init_model(wsdl_url, :url) do
IO.inspect(wsdl)
else
nil -> {:unknown_error}
_ -> {:unknown_error}
end
end
end
I have this error:
** (Protocol.UndefinedError) protocol Enumerable not implemented for nil. This protocol is implemented for: Ecto.Adapters.SQL.Stream, Postgrex.Stream, DBConnection.Stream, DBConnection.PrepareStream, Scrivener.Page, HashSet, Range, Map, Function, List, Stream, Date.Range, HashDict, GenEvent.Stream, MapSet, File.Stream, IO.Stream
(elixir) /private/tmp/elixir-20190114-93661-1hq8sk/elixir-1.8.0/lib/elixir/lib/enum.ex:1: Enumerable.impl_for!/1
(elixir) /private/tmp/elixir-20190114-93661-1hq8sk/elixir-1.8.0/lib/elixir/lib/enum.ex:141: Enumerable.reduce/3
(elixir) lib/stream.ex:936: Stream.do_enum_transform/7
(elixir) lib/stream.ex:860: Stream.do_transform/5
(sweet_xml) lib/sweet_xml.ex:582: anonymous fn/4 in SweetXml.continuation_opts/2
(xmerl) xmerl_scan.erl:568: :xmerl_scan.scan_document/2
(xmerl) xmerl_scan.erl:291: :xmerl_scan.string/2
(sweet_xml) lib/sweet_xml.ex:237: SweetXml.parse/2
(sweet_xml) lib/sweet_xml.ex:421: SweetXml.xpath/2
(sweet_xml) lib/sweet_xml.ex:531: anonymous fn/3 in SweetXml.xmap/3
(elixir) lib/map.ex:791: Map.get_and_update/3
(sweet_xml) lib/sweet_xml.ex:531: SweetXml.xmap/3
(sweet_xml) lib/sweet_xml.ex:530: SweetXml.xmap/3
(soap) lib/soap/wsdl.ex:37: Soap.Wsdl.parse/3
(khatoghalam) lib/khatoghalam/extera/bank/saman.ex:4: Khatoghalam.Extera.Bank.Saman.get_saman_token/0
How can I fix this ?
I think this def doesn't work
@spec get_schema_attributes(String.t()) :: map()
defp get_schema_attributes(wsdl) do
wsdl
|> xpath(
~x"//*[local-name() = 'schema']",
target_namespace: ~x"./@targetNamespace"s,
element_form_default: ~x"./@elementFormDefault"s
)
end
Nitrino commented
Hi @shahryarjb
Sorry for the long answer. PR #81 should fix your issue.