Posts Tagged ‘Code first validation’
Apache CXF – Code First – Schema validation demystified
In my previous article, I talked about how you can use schemaLocation property to override default CXF behaviour for Code First approach. But the approach had one major problem – Defining entire schema structure in one XSD file.
After spending few hours finding an option to get rid of this problem, I could finally found one tweak. The tweak is all about configuration and having an appropriate directory structure so that CXF can make use of already defined XSD structure to validate SOAP requests. Just follow next few steps, we will be evaluating it by considering one sample example.
1. Define XSD with required structure and include/import the XSDs you want to define as common structures. In my case here is the XSD structure.

2. The starting point for above structure is valueobjects.xsd and it includes one more XSD. (common/commontypes.xsd). The type of firstName element is referenced from commontypes.xsd.
valueobjects.xsd
CommonTypes.xsd
Apache CXF and validation
The ease of development provided by CXF for webservices has been key factor for its popularity amongst developers. Support for various WS-* standards and pluggable extensions are unique features of CXF.


