I'm implementing a SOAP client in Perl. The server it will send requests to has made available its WSDL and XSD schemas, and I've downloaded them locally to my computer. Now, the API is vast(!), and there is more than 150 schemas (two .wsdl and the rest .xsd) files.
If I use the opensource SoapUI, I may import only the wsdls and everything works perfectly out of the box; requests are sent and appropriate responses are returned: cool!
Now, I'm trying to implement a client in Perl,
use XML::Compile::WSDL11;
my $wsdl = XML::Compile::WSDL11->new;
$wsdl->addWSDL("schema/wsdl/MySuperService.wsdl");
$wsdl->importDefinitions("schema/xsd/MySuperService.xsd");
$wsdl->compileCalls(address => "https://my-web-host:4242/my-super-service");
All other .xsd are nested by import as
<xs:import namespace="SomeNameSpace" schemaLocation="relative/path/to/an.xsd"/>
or with include statements like
<xs:include schemaLocation="rel/path/to/another.xsd/>
I understand the documentation of XSD schemas such that import brings in definitions by their own namespace, while include brings the included definitions into the includer's namespace.
Now, here's the problem: the importDefinitions() from XML::Compile::WSDL11 does NOT support nested schema files. Thus, they all have to be imported manually. This is sort of made a little simpler by the use of glob. However, the function is also unable to distinguish between import and include!
For all xsd files that are included (not imported), the compileCalls() fails because the compiler is unable to find the type-definitions in files from included schemas:
error: cannot find type {parent-namespace}SomeCustomType ...
Obviously, because the definitions were not correctly included into the parent's namespace. I verified this by manually editing some of the included schemas, explicitly adding targetNamespace="parent-namespace" within the <xs:schema ..> attribute of the included schemas.. and it worked!
So, do I really have to manually edit ALL of the inclusions, or does it exist a better approach than the importDefinitions(glob "mySchema/*xsd") function that will deal with import and include appropriately?