You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Jason Chaffee <jc...@ebates.com> on 2010/07/30 01:39:02 UTC

issue with schma validation

I am having a problem with schema validation with jaxrs in 2.2.9.

 

If I specify a single schemaLocation CXF seems to use the scheama, if I
try specify multiple schemas it is not using them.  The problem with
using just one is that the other services stop working.  Any ideas?

 

For example,

 

 

This works:

    <jaxrs:schemaLocations>

 
<jaxrs:schemaLocation>classpath:/category.xsd</jaxrs:schemaLocation>

    </jaxrs:schemaLocations>

 

 

This doesn't work:

    <jaxrs:schemaLocations>

 
<jaxrs:schemaLocation>classpath:/category.xsd</jaxrs:schemaLocation>

 
<jaxrs:schemaLocation>classpath:/coupon.xsd</jaxrs:schemaLocation>

       <jaxrs:schemaLocation>classpath:/error.xsd</jaxrs:schemaLocation>

       <jaxrs:schemaLocation>classpath:/image.xsd</jaxrs:schemaLocation>

       <jaxrs:schemaLocation>classpath:/store.xsd</jaxrs:schemaLocation>

       <jaxrs:schemaLocation>classpath:/terms.xsd</jaxrs:schemaLocation>

    </jaxrs:schemaLocations>

 


Re: issue with schma validation

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

On Fri, Jul 30, 2010 at 12:39 AM, Jason Chaffee <jc...@ebates.com> wrote:

> I am having a problem with schema validation with jaxrs in 2.2.9.
>
>
>
> If I specify a single schemaLocation CXF seems to use the scheama, if I
> try specify multiple schemas it is not using them.  The problem with
> using just one is that the other services stop working.  Any ideas?
>
>
>
> For example,
>
>
>
>
>
> This works:
>
>    <jaxrs:schemaLocations>
>
>
> <jaxrs:schemaLocation>classpath:/category.xsd</jaxrs:schemaLocation>
>
>    </jaxrs:schemaLocations>
>
>
>
>
>
> This doesn't work:
>
>    <jaxrs:schemaLocations>
>
>
> <jaxrs:schemaLocation>classpath:/category.xsd</jaxrs:schemaLocation>
>
>
> <jaxrs:schemaLocation>classpath:/coupon.xsd</jaxrs:schemaLocation>
>
>       <jaxrs:schemaLocation>classpath:/error.xsd</jaxrs:schemaLocation>
>
>       <jaxrs:schemaLocation>classpath:/image.xsd</jaxrs:sfchemaLocation>
>
>       <jaxrs:schemaLocation>classpath:/store.xsd</jaxrs:schemaLocation>
>
>       <jaxrs:schemaLocation>classpath:/terms.xsd</jaxrs:schemaLocation>
>
>    </jaxrs:schemaLocations>
>
>
>
>
All the schemas are supposed to be connected either through include or
import statements. If you'd like different schemas be used for validating
different services then introduce multiple jaxrs:server endpoints instead.
(JAXP) Schema is created from a list of schemas but I'm just thinking that
if schemas are unrelated then either the 1st one or the last one in the list
is probably used....

Though you might want to try another approach if you do need to keep all the
root resources under a single jaxrs server endpoint.
I recall you were asking the other day how to enable the validation for the
specific (root) resources only and I suggested to register a custom
JAXBElementProvider which either 'hides' or does not the Schema for
individual invocations. But now you might want just to create a custom
MessageBodyReader, a composite one, initialized with a map of something
identifying a particular root resource to JAXBElementProvider pairs, where
each JAXBElementProvider  is initialized with specific schemas. So this
composite provider would just delegate to an appropriate
JAXBElementProvider



cheers, Sergey