I have a number of required soap headers defined in XSDs that I am not allowed to change, as existing clients are already using these in production.
In one of these schemas there are a number of imports with the same namespace value. When I attempt loading this schema into my validation interceptor I get an exception saying that the sdsd:SystemName (2nd element in the sequence) is undefined. If I open the XSD in IntelliJ Idea 13 I get red markings for sdsd:SystemName and the rest of the list of elements. Only the sdsd:SystemOwnerName is found and loaded.
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:sdsd="http://www.sdsd.dk/dgws/2010/08" xmlns:sdsd201206="http://www.sdsd.dk/dgws/2012/06" targetNamespace="http://www.sdsd.dk/dgws/2012/06" elementFormDefault="qualified" attributeFormDefault="unqualified">
<import namespace="http://www.sdsd.dk/dgws/2010/08" schemaLocation="../../2010/08/SystemOwnerName.xsd" />
<import namespace="http://www.sdsd.dk/dgws/2010/08" schemaLocation="../../2010/08/SystemName.xsd" />
<import namespace="http://www.sdsd.dk/dgws/2010/08" schemaLocation="../../2010/08/SystemVersion.xsd" />
<import namespace="http://www.sdsd.dk/dgws/2010/08" schemaLocation="../../2010/08/OrgResponsibleName.xsd" />
<import namespace="http://www.sdsd.dk/dgws/2010/08" schemaLocation="../../2010/08/OrgUsingName.xsd" />
<import namespace="http://www.sdsd.dk/dgws/2010/08" schemaLocation="../../2010/08/OrgUsingID.xsd" />
<import namespace="http://www.sdsd.dk/dgws/2010/08" schemaLocation="../../2010/08/RequestedRole.xsd" />
<element name="WhitelistingHeader" type="sdsd201206:WhitelistingHeader">
<annotation>
<documentation xml:lang="en-GB">SDSD Whitelisting header.</documentation>
<documentation xml:lang="da-DK">SDSD Whitelisting header.</documentation>
</annotation>
</element>
<complexType name="WhitelistingHeader">
<sequence>
<element ref="sdsd:SystemOwnerName" minOccurs="1" maxOccurs="1" />
<element ref="sdsd:SystemName" minOccurs="1" maxOccurs="1" />
<element ref="sdsd:SystemVersion" minOccurs="1" maxOccurs="1" />
<element ref="sdsd:OrgResponsibleName" minOccurs="1" maxOccurs="1" />
<element ref="sdsd:OrgUsingName" minOccurs="1" maxOccurs="1" />
<element ref="sdsd:OrgUsingID" minOccurs="1" maxOccurs="1" />
<element ref="sdsd:RequestedRole" minOccurs="1" maxOccurs="1" />
</sequence>
</complexType>
`
I have read this thread One xml namespace equals one and only one schema file? and can confirm that if I make a new 'master' schema that includes the schemas that are imported in the schema shown above and then change the imports in the schema shown above to a single include of the 'master' schema my Spring-ws validation interceptor is working correctly.
However since changing the schema is not an option I am looking for other options.
I have found Xerces documentation and Validate XML with loading schemas at runtime, failure depending on schema order suggesting that I can set the feature "http://apache.org/xml/features/validation/schema/handle-multiple-imports" to true on the XmlSchemaFactory in order to make Xerces not fail when validating a schema with multiple imports to the same namespace. However I have my own SoapHeaderValidatingInterceptor that extends the AbstractValidatingInterceptor, which in turn uses the Spring WS internal XmlValidatorFactory to create the XmlValidator that is used to validate the XSDs.
Any tips as to how I can enable the handle-multiple-imports feature will be greatly appreciated.