My camel cxf (2.15.2) route is working fine. Then requirement says we need to validate soap request against xsd. I try adding validator component:
from ("direct:xxx")
.to("validator:/path/to/CustomerRequest.xsd")
My CustomerRequest.xsd has imported other xsd(s).
<xsd:import schemaLocation="../vo/Address.xsd" namespace="http://vo.customer.com" />
<xsd:import schemaLocation="../vo/CustSourceEnum.xsd" namespace="http://vo.customer.com"></xsd:import>
but when I run start app, error happens. It complains about CustSourceEnum
org.apache.camel.FailedToCreateProducerException: Failed to create Producer for endpoint: Endpoint[validator:/path/to/xsd/CustomerRequest.xsd].
Reason: org.xml.sax.SAXParseException; lineNumber: 27; columnNumber: 115; src-resolve: Cannot resolve the name 'vo:CustSourceEnum' to a(n) 'type definition' component.
at org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:407)
...
Caused by: org.xml.sax.SAXParseException; lineNumber: 27; columnNumber: 115; src-resolve: Cannot resolve the name 'vo:CustSourceEnum' to a(n) 'type definition' component.
I double checked all the references in xsd are okay.
Now, the weird thing is if I change the order of import: Address first, and then CustSourceEnum:
<xsd:import schemaLocation="../vo/CustSourceEnum.xsd" namespace="http://vo.customer.com"></xsd:import>
<xsd:import schemaLocation="../vo/Address.xsd" namespace="http://vo.customer.com" />
Then an error still happens, BUT now it complains about 'vo:Address'.
If I try to modify CustomerRequest.xsd
just to import ONLY ONE schema, then it works. And of course, if I remove the camel validator component then everything works fine again.