Hi Steve:

1) I meant erlsoap, which Chandru uses in his suggestion:

compile_wsdl(Wsdl, Wsdl_erlsoap_config) ->
    Header_file_name = filename:basename(Wsdl, ".wsdl") ++ ".hrl",
    Model_header_file_name = filename:basename(Wsdl, ".wsdl") ++ "_model.hrl",
    Model = erlsoap_lib:initModelFile(   <=========== HERE
    ok = erlsoap_lib:write_hrl(Model, Header_file_name),  <==== HERE
    {ok, Iod} = file:open(Model_header_file_name, [write]),
    io:format(Iod, "-define(~s_MODEL, ~p).~n", [filename:basename(Wsdl, ".wsdl"), Model]),

I already have erlsom which is a prereq for yaws SOAP support.

2) The problem was not with include_files in the config.  The problem was as follows:
* My WSDL imports two XSDs
* The XSDs use different namespaces
* Both XSDs contain a declaration of Document element
* This is not a problem in XML because the namespace does what it's supposed to and de-duplicates the names
* Running yaws_soap_lib:write_hrl against the WSDL results in all record definitions using the same prefix P:, hence duplicate record names 'P:Document' with different structures
* Despite trying many different combinations of namespaces in the WSDL and the (undocumented?) yaws_soap_config file (import_files), I was unable to persuade yaws to generate record definitions with different prefixes for the two imported XSDs.
* My fix was to enable the erlsom Options to be passed into yaws.  I passed an include_fun thus:

findFile2(Namespace, Location, IncludeFiles, IncludeDirs) ->
  Map = [{"urn:iso:std:iso:20022:tech:xsd:pacs.008.001.02","ct"},
  case lists:keyfind(Namespace, 1, Map) of
    {_, Prefix} ->
        erlsom_lib:findFile(Namespace, Location, [{Namespace,Prefix,undefined}], IncludeDirs);
    _ ->
        erlsom_lib:findFile(Namespace, Location, IncludeFiles, IncludeDirs)

and that fixed the problem - I get the ct: prefix on the pacs.008 namespace records, and the psr: prefix on the pacs.002.

If you have a more elegant way of achieving the same result, I'd really appreciate it !


On Mon, Aug 9, 2010 at 2:23 PM, Steve Vinoski <vinoski@ieee.org> wrote:
On Mon, Aug 9, 2010 at 9:15 AM, Tom Hay <tomhay99@googlemail.com> wrote:
> I finally achieved what I needed, but it was hard work !
> I added a new function yaws_soap_lib:initModelOptions that allows me to pass
> in erlsom options, instead of faking them in yaws_soap_lib:initModel2; also
> a new function yaws_soap_srv:setupOptions that allows me to use the new
> initialisation in the server.  That allowed me to pass in a custom
> include_fun that applies the appropriate prefix for the namespaces I'm
> interested in.  I'd be happy to contribute the code back to yaws if a
> committer is interested.
> Chandru's suggestion gave me the clues I needed, but I struggled with it a)
> because erlsoap is virtually unobtainable (sources seem to have vanished
> from sourceforge) and b) because yaws scans the wsdl file and automatically
> pulls in the xsd schemas, and doesn't seem to honour the include_files
> options in the config file.

Thanks for digging into this. Questions:

1. Did you mean erlsom, rather than erlsoap? If so, the erlsom sources are here:


2. If there's a problem with include_files in the config file, do you
think it would be preferable to fix that rather than adding new