Hi all,

I'm afraid to say I've given up trying to get this to work.

Where I got to was:

- Implemented an interceptor to create an XMLStreamReader and set it in
the message.

Once that was done, I discovered that even though the AegisDatabinding
sets XmlSchemas on the ServiceInfo objects, those ServiceInfo objects
weren't ever kept anywhere, so when they were used in the
AegisSchemaValidationInInterceptor the schemas were there. So I made the
following changes:

- Extended JAXRSServiceImpl to initialise the service info objects once,
and always keep those copies.
- Extended JAXRSServiceFactoryBean to use my JAXRSServiceBean extended
class
- Switched spring config to vanilla bean declarations, so that I could
use my own JAXRSServiceFactoryBean as a constructor-arg to
JAXRSServerFactoryBean

Where I got stuck was:

- Validation seems to now be set up correctly - I see log output from
Stax2ValidationUtils for each schema fragment. However, when passing in
some invalid XML, the ValidationProblemHandler is never triggered.

If anyone has any suggestions for how to get faults to be returned, I'd
be happy to keep trying.

Cheers,
James


-----Original Message-----
From: Phillpotts, James [mailto:[email protected]] 
Sent: 20 October 2011 12:19
To: [email protected]
Subject: Schema Validation in JAX-RS service using Aegis data bindings

Hi all,

I wonder if anyone might be able to give me some pointers about using
schema validation in JAX-RS services?

I've currently got spring config:

        <bean id="aegisBean"
class="acme.services.ws.databinding.aegis.AegisDatabinding"
scope="singleton"/>

        <jaxrs:server id="restServer" address="/rest">
                <jaxrs:properties>
                        <entry key="schema-validation-enabled"><ref
bean="isValidateIncomingEAIMessages" /></entry>
                </jaxrs:properties>
                <jaxrs:serviceBeans>
                        <ref bean="bookstoreService" />
                </jaxrs:serviceBeans>
                <jaxrs:dataBinding><ref
bean="aegisBean"/></jaxrs:dataBinding>
        </jaxrs:server>

This does successfully enable schema validation in
AegisSchemaValidationInInterceptor, but I get a null pointer exception:

java.lang.NullPointerException
        at
org.apache.cxf.wstx_msv_validation.Stax2ValidationUtils.setupValidation(
Stax2ValidationUtils.java:71)
        at
org.apache.cxf.wstx_msv_validation.WoodstoxValidationImpl.setupValidatio
n(WoodstoxValidationImpl.java:67)
        at
org.apache.cxf.aegis.databinding.AegisSchemaValidationInInterceptor.setS
chemaInMessage(AegisSchemaValidationInInterceptor.java:68)
        at
org.apache.cxf.aegis.databinding.AegisSchemaValidationInInterceptor.hand
leMessage(AegisSchemaValidationInInterceptor.java:56)

>From debugging, the XMLStreamReader is null. This is presumably because
somewhere along the way, the JAX-WS service/interceptors set a
XMLStreamReader in the message, but the JAX-RS ones don't.

My next step was going to be creating an interceptor that sets a
XMLStreamReader in the message for any message received whose content is
XML. Is this sensible? Is there something else I should be doing?

Thanks in advance,
James


PS - sorry for the auto-legal-waffle...



Information in this e-mail and any attachments is confidential, and may
not be copied or used by anyone other than the addressee, nor disclosed
to any third party without our permission. There is no intention to
create any legally binding contract or other binding commitment through
the use of this electronic communication unless it is issued in
accordance with the Experian Limited standard terms and conditions of
purchase or other express written agreement between Experian Limited and
the recipient. Although Experian has taken reasonable steps to ensure
that this communication and any attachments are free from computer
virus, you are advised to take your own steps to ensure that they are
actually virus free. 

Companies Act information: Registered name: Experian Limited. Registered
office: Landmark House, Experian Way, NG2 Business Park, Nottingham,
NG80 1ZZ, United Kingdom. Place of registration: England and Wales.
Registered number: 653331

Reply via email to