bet365 / soap

Make it easy to use SOAP from Erlang
Apache License 2.0
200 stars 74 forks source link

wsdl2erlang client generation: Namespace not found #32

Open sveinfid opened 6 years ago

sveinfid commented 6 years ago

I'm trying to generate a client using wsdl2erlang, and I'm seeing the following error "Namespace not found".

Any ideas what could be wrong here?

The namespace in question is without a http:// prefix, could that be the issue?

2> soap:wsdl2erlang("http://my_host/path?wsdl"). What must be generated? 1: client 2: server 3: both Select a number: 1

Do you want to generate test stubs/skeletons? 1: no 2: yes, client only 3: yes, server only 4: yes, client and server Select a number: 2

Which http client must be used? 1: ibrowse 2: inets Select a number: 2 ** exception error: no match of right hand side value {error, "Namespace not found my.namespace.here"} in function soap_parse_wsdl:add_schemas/5 (src/soap_parse_wsdl.erl, line 213) in call from soap_parse_wsdl:parse_wsdls/3 (src/soap_parse_wsdl.erl, line 146) in call from soap_parse_wsdl:file/4 (src/soap_parse_wsdl.erl, line 80) in call from soap_parse_wsdl:get_model/2 (src/soap_parse_wsdl.erl, line 55) in call from soap_parse_wsdl:get_namespaces/2 (src/soap_parse_wsdl.erl, line 66) in call from soap:wsdl2erlang/2 (src/soap.erl, line 313)

willemdj commented 6 years ago

(Probably this response comes too late to help you, but in case other people run into this problem)

If the location of the include file starts with "http://" or "https://", soap:wsdl2erlang will try to retrieve it from the url. If not, it will try to get it from disk.

You can modify this behavior by providing an erlsom_option (erlsom is the parser that is used to parse the WSDL). Erlsom offers various options to find included files, for example you can pass a list of directories or your own function to locate the XSD given the namespace.

elielhaouzi commented 5 years ago

Hi @sveinfid, did you success to resolve the bug of "Namespace not found.." ? I have the same error.

@willemdj can you explain how to pass option to erlsom to fix this bug ?

Thanks

willemdj commented 5 years ago

Something like:

soap:wsdl2erlang("http://my_host/path?wsdl", [{erlsom_options, [{include_fun, IncludeFun}]]).

where IncludeFun is a function that finds the files that are included or imported in the XSD. It should be a function that takes 4 arguments:

Include_fun should return {XSD, Prefix}, where XSD is a XSD = string(), Prefix = string or 'undefined' - if the value is undefined, ‘P’ will be used.

There are other erlsom_options that you might use, for example you can pass the name of a directory where the files are located. See https://github.com/willemdj/erlsom/blob/master/doc/reference.md#compile_xsd