anchor.diff:  initModel2(WsdlFile, Prefix, Path, Import, AddFiles) ->
       WsdlName = filename:join([Path, "wsdl.xsd"]),
       IncludeWsdl = {"http://schemas.xmlsoap.org/wsdl/", "wsdl", WsdlName},
  -    {ok, WsdlModel} = erlsom:compile_xsd_file(filename:join([Path,"soap.xsd"]), 
  -                                              [{prefix, "soap"},
  -                                               {include_files, [IncludeWsdl]}]),
  +    {ok, WsdlModel} = erlsom:compile_xsd_file(filename:join([Path, "soap.xsd"]), 
  +					      [{prefix, "soap"},
  +					       {include_files, [IncludeWsdl]}]),
       %% add the xsd model (since xsd is also used in the wsdl)
       WsdlModel2 = erlsom:add_xsd_model(WsdlModel),
  +    Options = makeOptions(Import),
       %% parse Wsdl
  -    {ok, WsdlFileContent} = get_url_file(rmsp(WsdlFile)),
  -    {ok, ParsedWsdl} = erlsom:parse(WsdlFileContent, WsdlModel2),
  -    %% get the xsd elements from this model, and hand it over to erlsom_compile.
  -    Xsd = getXsdFromWsdl(ParsedWsdl),
  -    %% Ns = [#ns{prefix="xsd", uri="http://www.w3.org/2001/XMLSchema"}],
  -    %% TODO: pass the right options here
  -    Options = makeOptions(Import),
  -    {ok, Model} = erlsom_compile:compile_parsed_xsd(
  -                    Xsd, [{prefix, Prefix} | Options]),
  +    {Model, Operations} = parseWsdls([WsdlFile], Prefix, WsdlModel2, Options, {undefined, []}),
       %% TODO: add files as required
       %% now compile envelope.xsd, and add Model
  -    {ok, EnvelopeModel} = erlsom:compile_xsd_file(
  -                            filename:join([Path, "envelope.xsd"]),
  -                            [{prefix, "soap"}]),
  +    {ok, EnvelopeModel} = erlsom:compile_xsd_file(filename:join([Path, "envelope.xsd"]),
  +						  [{prefix, "soap"}]),
       SoapModel = erlsom:add_model(EnvelopeModel, Model),
       SoapModel2 = addModels(AddFiles, SoapModel),
  -    Ports = getPorts(ParsedWsdl),
  -    Operations = getOperations(ParsedWsdl, Ports),
       #wsdl{operations = Operations, model = SoapModel2}.
   
   
  +%%% --------------------------------------------------------------------
  +%%% Parse a list of WSDLs and import (recursively)
  +%%% Returns {Model, Operations}
  +%%% --------------------------------------------------------------------
  +parseWsdls([], _Prefix, _WsdlModel, _Options, Acc) ->
  +  Acc;
  +parseWsdls([WsdlFile | Tail], Prefix, WsdlModel, Options, {AccModel, AccOperations}) ->
  +  {ok, WsdlFileContent} = get_url_file(rmsp(WsdlFile)),
  +  {ok, ParsedWsdl, _} = erlsom:scan(WsdlFileContent, WsdlModel),
  +  %% get the xsd elements from this model, and hand it over to erlsom_compile.
  +  Xsds = getXsdsFromWsdl(ParsedWsdl),
  +  %% Now we need to build a list: [{Namespace, Xsd, Prefix}, ...] for all the Xsds in the WSDL.
  +  %% This list is used when a schema inlcudes one of the other schemas. The AXIS java2wsdl 
  +  %% generates wsdls that depend on this feature. 
  +  ImportList = makeImportList(Xsds, []),
  +  %% TODO: pass the right options here
  +  Model2 = addSchemas(Xsds, AccModel, Prefix, Options, ImportList),
  +  Ports = getPorts(ParsedWsdl),
  +  Operations = getOperations(ParsedWsdl, Ports),
  +  Imports = getImports(ParsedWsdl),
  +  Acc2 = {Model2, Operations ++ AccOperations},  
  +  %% process imports (recursively, so that imports in the imported files are 
  +  %% processed as well).
  +  %% For the moment, the namespace is ignored on operations etc. 
  +  %% this makes it a bit easier to deal with imported wsdl's.
  +  Acc3 = parseWsdls(Imports, Prefix, WsdlModel, Options, Acc2),
  +  parseWsdls(Tail, Prefix, WsdlModel, Options, Acc3).
  +
  +%%% --------------------------------------------------------------------
  +%%% build a list: [{Namespace, Xsd}, ...] for all the Xsds in the WSDL.
  +%%% This list is used when a schema inlcudes one of the other schemas. The AXIS java2wsdl 
  +%%% generates wsdls that depend on this feature. 
  +makeImportList([], Acc) ->
  +  Acc;
  +makeImportList([#schemaType{targetNamespace = Tns} = Xsd | Tail], Acc) ->
  +  makeImportList(Tail, [{Tns, undefined, Xsd} | Acc]).
  +  
  +
  +%%% --------------------------------------------------------------------
  +%%% compile each of the schemas, and add it to the model.
  +%%% Returns Model
  +%%% (TODO: using the same prefix for all XSDS makes no sense)
  +%%% --------------------------------------------------------------------
  +addSchemas([], AccModel, _Prefix, _Options, _ImportList) ->
  +  AccModel;
  +addSchemas([Xsd| Tail], AccModel, Prefix, Options, ImportList) ->
  +  Model2 = case Xsd of
  +             undefined -> 
  +               AccModel;
  +             _ -> 
  +               {ok, Model} = 
  +                 erlsom_compile:compile_parsed_xsd(Xsd, 
  +                                                   [{prefix, Prefix},
  +                                                    {include_files, ImportList} |Options]),
  +               case AccModel of 
  +                 undefined -> Model;
  +                 _ -> erlsom:add_model(AccModel, Model)
  +               end
  +           end,
  +  addSchemas(Tail, Model2, Prefix, Options, ImportList).
   
   %%% --------------------------------------------------------------------
   %%% Get a file from an URL spec.
   %%% --------------------------------------------------------------------
   get_url_file("http://"++_ = URL) ->
       case http:request(URL) of
  -        {ok,{{_HTTP,200,_OK}, _Headers, Body}} -> 
  -            case http_uri:parse(URL) of
  -                {_Method, _Host, _Port, _Path, _Qargs} ->
  -                    %% Erlang/OTP =< R11B-1
  -                    {ok, Body};
  -                {_Method, _UserInfo, _Host, _Port, _Path, _Qargs} ->
  -                    %% Erlang/OTP >= R11B-2
  -                    {ok, Body};
  -                _ -> 
  -                    {error, "failed to parse URL: "++URL}
  -            end;
  -        {ok,{{_HTTP,RC,Emsg}, _Headers, _Body}} -> 
  -            error_logger:error_msg("~p: http-request got: ~p~n", 
  -                                   [?MODULE, {RC, Emsg}]),
  -            {error, "failed to retrieve: "++URL};
  -        _ -> 
  -            error_logger:error_msg("~p: http-request failed~n", []),
  -            {error, "failed to retrieve: "++URL}
  +	{ok,{{_HTTP,200,_OK}, _Headers, Body}} -> 
  +	    {ok, Body};
  +	{ok,{{_HTTP,RC,Emsg}, _Headers, _Body}} -> 
  +	    error_logger:error_msg("~p: http-request got: ~p~n", [?MODULE, {RC, Emsg}]),
  +	    {error, "failed to retrieve: "++URL};
  +	_ -> 
  +	    error_logger:error_msg("~p: http-request failed~n", []),
  +	    {error, "failed to retrieve: "++URL}
       end;
   get_url_file("file://"++Fname) ->
       {ok, Bin} = file:read_file(Fname),
  +    {ok, binary_to_list(Bin)};
  +%% added this, since this is what is used in many WSDLs (i.e.: just a filename).
  +get_url_file(Fname) ->
  +    {ok, Bin} = file:read_file(Fname),
       {ok, binary_to_list(Bin)}.
   
   
  
positive.code: %% -record(xsd_file, {atts, name, prefix, import_specs}).
  addModel(undefined, Acc) ->
    Acc;
  addModel(#xsd_file{name = XsdFile, prefix = Prefix, 
                     import_specs = Import}, Acc) ->
    Options = makeOptions(Import),
    {ok, Model2} = erlsom:add_xsd_file(XsdFile, [{prefix, Prefix} |Options], Acc),
    Model2.
  
  %% returns [#port{}]
  
negative.code: %%% Author  : Willem de Jong (w.a.de.jong@gmail.com).
  %%% Desc.   : Common SOAP code.
  %%%-------------------------------------------------------------------
  
  %%% modified (WdJ, May 2007): deal with imports in the WSDL.
  %%% modified (WdJ, August 2007): the WSDL can contain more than 1 schema
  
  -module(yaws_soap_lib).
  
  -export([initModel/1, initModel/2, 
  	 initModelFile/1,
  	 config_file_xsd/0,
  	 call/3, call/4, call/6,
  	 write_hrl/2, write_hrl/3,
  	 findHeader/2,
  	 parseMessage/2,
  	 makeFault/2,
  	 is_wsdl/1, wsdl_model/1, wsdl_op_service/1,
  	 wsdl_op_port/1, wsdl_op_operation/1, 
  	 wsdl_op_binding/1, wsdl_op_address/1, 
  	 wsdl_op_action/1, wsdl_operations/1,
  	 get_operation/2
  	]).
  
  
  %%% For testing...
  