Hi
I might've replied to this message before - sorry for any duplication if it's
the case
Please see
http://svn.apache.org/repos/asf/cxf/trunk/systests/src/test/resources/jaxrs/WEB-INF/beans.xml
for an example of how one can configure both JAXB and JSON providers to do the input validation, in this case showing how one can
share the (in memory) schema resources, with multiple schemas involved. If you do JAXB or JSON only then there's no need to use
SchemaHandler bean and a schemas list can also be as a property
If you have one schema importing the other one then the xs:import statement should not have a schemaLocation attribute, only a
namespace attribute one (in case this schema is a classpath resource) :
http://svn.apache.org/repos/asf/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/book.xsd
and then add it as part of the schema list as shown in the configuration sample
Cheers, Sergey
Hi all,
I develop a RESTful Web Service following the tutorial on CXF Website
(http://cwiki.apache.org/CXF20DOC/jax-rs-jsr-311.html).
To marshall/unmarshall the request and response, I use JAXB.
The request is defined as follows:
@XmlRootElement(name="orderRequest")
@XmlAccessorType(XmlAccessType.FIELD)
public class OrderRequest {
private AuthorizationRequest authorizationRequest;
@XmlElement(required=true, nillable=false)
private URI confirmationURL;
private PurchaseRequest purchaseRequest;
//getters and setters
...
}
The code for the RESTful Web Service is given below:
@Path("/ideal/")
public class IdealPaymentService {
@POST
@Path("/submitOrder/")
public Response submitOrder(OrderRequest orderRequest) throws
URISyntaxException {
System.out.println("----invoking submitOrder" + orderRequest.toString());
return Response.ok("http://www.google.com").build();
}
}
The service is published by JAXRSServerFactoryBean in the Spring context:
...
<!-- Initialize JAXRSServer -->
<jaxrs:server id="restServices" address="/payment">
<jaxrs:serviceBeans>
<ref bean="idealPaymentService" />
</jaxrs:serviceBeans>
</jaxrs:server>
<bean id="idealPaymentService"
class="com.lycoseurope.cbp.ideal.restful.service.IdealPaymentService" />
...
After the deployment, the service works perfectly, but the request is not correctly validated. I sent a request with a missing
confirmationURL, but I got no error message even though the confirmationURL has been specified as a mandatory XML element, which
is not nullable.
On publishing a web service using JAX-WS, we could set the option "schema-validation-enabled" to true in the spring context to
turn on the input validation. Is there a similar property in JAX-RS to enable input validation?
Thank you very much in advance.