I’m developing a web-service in some kind of contract-first terms – firstly, I create xsd schemes, secondly, generate classes with JAXB upon them, and then, I want to attach these schemes to WSDL. Here is my applicationContext,xml:
<jaxws:endpoint id="webService"
implementor="#wsImplementer"
address="/service">
<jaxws:schemaLocations>
<jaxws:schemaLocation>classpath:/xsd/RequestWrapper.xsd</jaxws:schemaLocation>
</jaxws:schemaLocations>
</jaxws:endpoint>
The problem is: the RequestWrapper.xsd contains <xs:include schemaLocation="ComplexTypes.xsd"/> and the
ComplexTypes.xsd contains <xs:include schemaLocation="SimpleTypes.xsd"/>. So, when CXF generates the WSDL, it contains the RequestWrapper.xsd scheme with such an include http://service/path?xsd=ComplexTypes.xsd which is ok, but if you walk to this link you’ll see ComplexTypes.xsd with <xs:include schemaLocation="SimpleTypes.xsd"/>. Of course, this is not a valid WSDL cause it cannot load the SimpleTypes.xsd.
I’ve managed to find the workaround:
1) create a new scheme which consists of includes:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://custom/data"
xmlns="http://custom/data">
<xs:include schemaLocation="SimpleTypes.xsd"/>
<xs:include schemaLocation="ComplexTypes.xsd"/>
<xs:include schemaLocation="RequestWrapper.xsd"/>
2) delete all the includes from the other schemes.
3)
<jaxws:schemaLocations>
<jaxws:schemaLocation>classpath:/xsd/comprise.xsd</jaxws:schemaLocation>
</jaxws:schemaLocations>
That worked for me, but, as you can see, all the schemes are not valid (there is no includes). That looks really dull to comment includes all the time before exposing a web service. Can anybody please help me? How to go through this?
So that, I need some kind of scheme location resolver…
I wonder why you specify xsd schemas in applicationContext.xml? May be i don’t fully understand your question but when i developed web services using JAXB simply included
So request wrapper includes other xsd files and you can make “includes” inside RequestWrapper.xsd as much as you need.
p.s. in xsd file import like this