You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Uma <um...@ioko.com> on 2011/03/29 18:30:02 UTC

CXF JAX-RS XML schema Validation

Hi,
  Iam using REST full webservices with JAX-RS  and JAXB annotations. 

  I need to validate incomming client request(xml) against Schema.I
configured in cxf-spring- xml to 
validate the request. 

I added web-service-impl-cxf-spring-context to use schema validation


  
     classpath:/generated-schema/schema1.xsd
   


Used maven-jaxb-schemagen-plugin to generate xsd schema. JAX-RS annonation
are used in model(POJO). 

I dont know why schema validation is not happening. If i pass some junk
value(eg:if i pass string value instead of long), jax-RS takes it as 'null'
while unmarshelling(I mean during xml to java) ...


http://cxf.apache.org/docs/jax-rs-data-bindings.html#JAX-RSDataBindings-Schemavalidation



I am not sure why it is ignorin..do I need to write any
validationEventHandler to take care of xsd validation.??
Can you please suggest me how do I go ahead with this?


--
View this message in context: http://cxf.547215.n5.nabble.com/CXF-JAX-RS-XML-schema-Validation-tp4269657p4269657.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: CXF JAX-RS XML schema Validation

Posted by Uma <um...@ioko.com>.
Hi,

Please note that its finding the resource(.xsd). Logs are below.I am not
getting any error ..But validations are not happening. I sent some invalid
values(in the request) ,jax-rs jaxb is considering null...it is not
identifiying the type. For example: I have field property called 'Offset' in
Model bean class.It is type of long.When I send 'string' value for that
property, jax-rs jaxb in MediaServiceImpl class,it is taking as
null....Looks like still validation is not enabled yet..


Starting up oesp webapp at http://localhost:8090/
to see a list of services use http://localhost:8090/services
[2011-03-30 09:20:28,399] [INFO ] [ServerImpl] (ServerImpl.java:93) -
Setting the server's publish address to be /
[2011-03-30 09:20:29,351] [INFO ] [AbstractCXFServlet] (CXFServlet.java:139)
- Load the bus with application context
[2011-03-30 09:20:29,355] [INFO ] [BusApplicationContext]
(AbstractApplicationContext.java:456) - Refreshing
org.apache.cxf.bus.spring.BusApplicationContext@1ad4feb: startup date [Wed
Mar 30 09:20:29 BST 2011]; parent: Root WebApplicationContext
[2011-03-30 09:20:29,408] [INFO ] [AbstractCXFServlet]
(AbstractCXFServlet.java:115) - Servlet transport factory already registered 

--
View this message in context: http://cxf.547215.n5.nabble.com/CXF-JAX-RS-XML-schema-Validation-tp4269657p4271001.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: CXF JAX-RS XML schema Validation

Posted by Uma <um...@ioko.com>.
I generated xsd using maven-schema-gen plugin..I can see that xsd is
generated in the path: target/generated-schema/schema1.xsd.

However In the logs I can see ,it is not able to find the schema file..

Logs below:

Starting up oesp webapp at http://localhost:8090/
to see a list of services use http://localhost:8090/services
[2011-03-29 18:35:47,395] [WARN ] [ResourceUtils] (ResourceUtils.java:391) -
No file resource generated-schema/schema1.xsd is available on local disk
[2011-03-29 18:35:47,784] [INFO ] [ServerImpl] (ServerImpl.java:93) -
Setting the server's publish address to be /
[2011-03-29 18:35:47,840] [WARN ] [ResourceUtils] (ResourceUtils.java:391) -
No file resource generated-schema/schema1.xsd is available on local disk
[2011-03-29 18:35:47,841] [WARN ] [ResourceUtils] (ResourceUtils.java:391) -
No file resource generated-schema/schema1.xsd is available on local disk
[2011-03-29 18:35:48,710] [INFO ] [AbstractCXFServlet] (CXFServlet.java:139)
- Load the bus with application context
[2011-03-29 18:35:48,714] [INFO ] [BusApplicationContext]
(AbstractApplicationContext.java:456) - Refreshing
org.apache.cxf.bus.spring.BusApplicationContext@4f12c2: startup date [Tue
Mar 29 18:35:48 BST 2011]; parent: Root WebApplicationContext
[2011-03-29 18:35:48,762] [INFO ] [AbstractCXFServlet]
(AbstractCXFServlet.java:115) - Servlet transport factory already registered 


--
View this message in context: http://cxf.547215.n5.nabble.com/CXF-JAX-RS-XML-schema-Validation-tp4269657p4269771.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: CXF JAX-RS XML schema Validation

Posted by Uma <um...@ioko.com>.
Thanks for the reply. Please find the attached file belows


http://cxf.547215.n5.nabble.com/file/n4269759/web-service-impl-cxf-spring-context.xml
web-service-impl-cxf-spring-context.xml 
http://cxf.547215.n5.nabble.com/file/n4269759/schema1.xsd schema1.xsd 
http://cxf.547215.n5.nabble.com/file/n4269759/MediaServiceImpl.java
MediaServiceImpl.java 
http://cxf.547215.n5.nabble.com/file/n4269759/MediaService.java
MediaService.java 
http://cxf.547215.n5.nabble.com/file/n4269759/MediaEvent.java
MediaEvent.java 



--
View this message in context: http://cxf.547215.n5.nabble.com/CXF-JAX-RS-XML-schema-Validation-tp4269657p4269759.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: CXF JAX-RS XML schema Validation

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

On Tue, Mar 29, 2011 at 5:30 PM, Uma <um...@ioko.com> wrote:

> Hi,
>  Iam using REST full webservices with JAX-RS  and JAXB annotations.
>
>  I need to validate incomming client request(xml) against Schema.I
> configured in cxf-spring- xml to
> validate the request.
>
> I added web-service-impl-cxf-spring-context to use schema validation
>
>
>
>     classpath:/generated-schema/schema1.xsd
>
>
>
> Used maven-jaxb-schemagen-plugin to generate xsd schema. JAX-RS annonation
> are used in model(POJO).
>
> I dont know why schema validation is not happening. If i pass some junk
> value(eg:if i pass string value instead of long), jax-RS takes it as 'null'
> while unmarshelling(I mean during xml to java) ...
>
>
>
> http://cxf.apache.org/docs/jax-rs-data-bindings.html#JAX-RSDataBindings-Schemavalidation
>
>
>
> I am not sure why it is ignorin..do I need to write any
> validationEventHandler to take care of xsd validation.??
> Can you please suggest me how do I go ahead with this?
>
>
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/CXF-JAX-RS-XML-schema-Validation-tp4269657p4269657.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>


Can you check the logs please, just wondering if schema has been found,
check warnings starting from:

"Validation will be disabled, failed to create schema"...

Also, you may want to send me a sample schema and sample classes, so that I
can check what the problem is...

Cheers, Sergey