Thanks Sergey.

It worked with 2.4.4
But there was no trace in the logs that indicates that the XSDs has been 
found(in both the versions).
So does it mean that validation is not supported in cxf 2.3.2??

Regards,
Neeraj

-----Original Message-----
From: Sergey Beryozkin [mailto:[email protected]] 
Sent: Friday, November 18, 2011 4:34 PM
To: [email protected]
Subject: Re: schema validation not working in cxf restful service

Hi

Can you check the logs please and see if schemas have been found ?
By the way, I'm presuming search.xsd imports types.xsd - I believe it's 
not needed to specify the imported schemas in later versions, try for 
example CXF 2.4.4 juts to confirm it

Sergey

On 18/11/11 10:24, AGGARWAL, NEERAJ (NEERAJ) wrote:
> Hello,
>
> I have designed a restful service. And I am trying to enable the validation 
> of the input request against the schema files.
> I added the following in my spring configuration file.
> <jaxrs:server id="restContainer" address="/rest/">
>              <jaxrs:serviceBeans>
>                    <ref bean="searchService" />
>              </jaxrs:serviceBeans>
>              <jaxrs:schemaLocations>
>                    
> <jaxrs:schemaLocation>classpath:/search.xsd</jaxrs:schemaLocation>
> <jaxrs:schemaLocation>classpath:/type.xsd</jaxrs:schemaLocation>
>              </jaxrs:schemaLocations>
>              <jaxrs:providers>
>                    <ref bean="jaxbProvider" />
>              </jaxrs:providers>
> </jaxrs:server>
>
> Both search.xsd and type.xsd are located parallel to META-INF and WEB-INF.
>
> Here is the schema for my input request-
> <complexType name="searchRequest">
>              <sequence>
>                    <element name="productName" type="ns1:productName"/>
>                    <element name="transactionType" 
> type="ns1:transactionType"/>
>                    <element name="searchCriterias" 
> type="ns1:searchCriteriaType"/>
>                    <element name="offset" type="int"/>
>                    <element name="pageCount" type="int"/>
>              </sequence>
> </complexType>
> <complexType name="searchCriteriaType">
>              <sequence>
>                    <element name="searchCriteria" maxOccurs="unbounded">
>                          <complexType>
>                                <sequence>
>                                      <element name="name" type="string"/>
>                                      <element name="value" type="string"/>
>                                </sequence>
>                          </complexType>
>                    </element>
>              </sequence>
> </complexType>
> <simpleType name="transactionType">
>              <restriction base="string"/>
> </simpleType>
>
> Here is the incorrect request I am sending expecting the CXF framework to 
> send me the error-
> <types:searchRequest xmlns:types="http://www.eras.com/ ">
>     <types:productName>SCF</types:productName>
>     <types:transactionType>TDR</types:transactionType>
>     <types:searchCriterias>
>              <types:searchCriteria>
>              </types:searchCriteria>
> <types:pageCount>1</types:pageCount>
>               <types:offset>0</types:offset>
>     </types:searchCriterias>
> </types:searchRequest>
>
> Why the above request is incorrect?
> Because 'pageCount' and 'offset' should come after 'searchCriterias' tag as 
> its sibling and not as its child.
>
> The Result-
> CXF is just ignoring 'pageCount' and 'offset' tags and returing the results.
>
> Version of CXF used- 2.3.2
>
> I have tried out both the ways mentioned at 
> http://cxf.apache.org/docs/jax-rs-data-bindings.html#JAX-RSDataBindings-Schemavalidation
>  but still my input request is not getting validated.
>
> Please suggest something.
>
> Regards,
> Neeraj Aggarwal
>


-- 
Sergey Beryozkin

http://sberyozkin.blogspot.com

Talend Community Coders
http://coders.talend.com/

Reply via email to