axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ruairiw <ruairi.wh...@fineos.com>
Subject Adding extra schema and validation to MessageReceiver classes
Date Tue, 16 Sep 2008 14:11:29 GMT

We have a requirement that the default MessageReceiver classes 
1) set a schema on the unmarshaller for validation purposes (the schema
points to separate xsd file that contains the types for the wsdl) 
and 
2) does some post validation like
MyValidationHandler.checkServiceTypeIsEmpty( ) below after the unmarshalling
has occured to validate the incoming message against the schema before the
incoming data is passed to the business logic.

 
private java.lang.Object fromOM (...) throws org.apache.axis2.AxisFault,
ValidationException  {

          try {
                javax.xml.bind.JAXBContext context =
classContextMap.get(type);
                javax.xml.bind.Unmarshaller unmarshaller =
context.createUnmarshaller();

               
unmarshaller.setSchema("/services/PartyServices/META-INF/PartyServicesOperations.xsd");
                unmarshaller.setEventHandler(new ValidationEventHandler());
         
                Object unmarshalledParam =
unmarshaller.unmarshal(param.getXMLStreamReaderWithoutCaching(),
type).getValue();

               
MyValidationHandler.checkServiceTypeIsEmpty(unmarshalledParam);

                return unmarshalledParam;
            catch (UnmarshalException unmarshalException){
                ValidationException validationException =
(ValidationException)JAXBTypeConverter.createValidationException(type.toString(),
new ValidationException(), unmarshalException);
                throw validationException;
            }
        
            catch (javax.xml.bind.JAXBException bex){
              throw org.apache.axis2.AxisFault.makeFault(bex);
            } 
        
            catch (org.xml.sax.SAXException saxException){
              throw org.apache.axis2.AxisFault.makeFault(saxException);
            }
}

Similar situation in the toOM method, i.e., do some extra validation before
sending the message out to the big bad world...
            private org.apache.axiom.om.OMElement toOM(...) ...{
...
               
MyValidationHandler.validateMarshallerAgainstSchema(("/services/PartyServices/META-INF/PartyServicesOperations.xsd",
marshaller, param);
                
                return factory.createOMElement(source,
"FindOrganisationResponse", namespace);

            }

Is there any hook 1) to set the schema on the unmarshaller and 2) perform
some task after the data is unmarshalled but before the business logic is
called (like we've done above)?
We have customised the xsl templates in axis2-codegen.jar and
axis2-jaxbri.jar to add the extra lines in all our generated
MessageReceivers (instead of specifying custom MessageReceivers for all our
wsdls) but would prefer some hook/call out in the default MessageReceiver,
similar to whats stated in  https://issues.apache.org/jira/browse/AXIS2-2927
https://issues.apache.org/jira/browse/AXIS2-2927 .

Thanks for any help,
Ruairi.
-- 
View this message in context: http://www.nabble.com/Adding-extra-schema-and-validation-to-MessageReceiver-classes-tp19512692p19512692.html
Sent from the Axis - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Mime
View raw message