axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ruairiw <>
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) 
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 =
                javax.xml.bind.Unmarshaller unmarshaller =

                unmarshaller.setEventHandler(new ValidationEventHandler());
                Object unmarshalledParam =


                return unmarshalledParam;
            catch (UnmarshalException unmarshalException){
                ValidationException validationException =
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 toOM(...) ...{
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 .

Thanks for any help,
View this message in context:
Sent from the Axis - Dev mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message