You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by jasminadesai <ja...@yahoo.com> on 2013/10/22 07:58:45 UTC

restful XML / JSON and schema validation

Hi,

My restful service supports both xml and json. Each method in the service
can accept either a xml request or a json request. Is there a way I can
validate the incoming requests that are in xml or json format.

My soap web service auto generates the wsdl and that has all the required
validations. These are generated from the annotations I have used in the
soap web service.

Is there any such thing in restful web service? Right now my wadl does get
generated, but how do we add the required condition for some of the
mandatory elements I have in my request.

Regards,
Jasmina



--
View this message in context: http://cxf.547215.n5.nabble.com/restful-XML-JSON-and-schema-validation-tp5735373.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: restful XML / JSON and schema validation

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 22/10/13 06:58, jasminadesai wrote:
> Hi,
>
> My restful service supports both xml and json. Each method in the service
> can accept either a xml request or a json request. Is there a way I can
> validate the incoming requests that are in xml or json format.
>
> My soap web service auto generates the wsdl and that has all the required
> validations. These are generated from the annotations I have used in the
> soap web service.
>
> Is there any such thing in restful web service? Right now my wadl does get
> generated, but how do we add the required condition for some of the
> mandatory elements I have in my request.
>

In order to do the schema validation with JAX-RS one needs to configure 
jaxrs:server/jaxrs:locations property, however if you use a default JSON 
provider and also validate in JSON then the better approach is to 
configure a SchemaHolder with the list of schemas and set it to 
JAXBElementProvider and JSONProvider,

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

HTH, Sergey

> Regards,
> Jasmina
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/restful-XML-JSON-and-schema-validation-tp5735373.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>



Re: restful XML / JSON and schema validation

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 22/10/13 06:58, jasminadesai wrote:
> Hi,
>
> My restful service supports both xml and json. Each method in the service
> can accept either a xml request or a json request. Is there a way I can
> validate the incoming requests that are in xml or json format.
>
> My soap web service auto generates the wsdl and that has all the required
> validations. These are generated from the annotations I have used in the
> soap web service.
>
> Is there any such thing in restful web service? Right now my wadl does get
> generated, but how do we add the required condition for some of the
> mandatory elements I have in my request.
>

In order to do the schema validation with JAX-RS one needs to configure 
jaxrs:server/jaxrs:locations property, however if you use a default JSON 
provider and also validate in JSON then the better approach is to 
configure a SchemaHolder with the list of schemas and set it to 
JAXBElementProvider and JSONProvider,

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

HTH, Sergey

> Regards,
> Jasmina
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/restful-XML-JSON-and-schema-validation-tp5735373.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>