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.



      

Reply via email to