You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Vishy <rk...@gmail.com> on 2006/05/02 15:25:58 UTC

Schema Validation

Hi,

I am using Axis 1.3

Can someone point me in the right direction, to accomplish the following?

1) Validate incoming/outgoing xml against a schema...the only place, where I
am thinking I can do this, is in a request or response handler...am I
correct? has anyone done this before?

2) How can I avoid throwing IllegalArgumentExceptions or Invalid Date/Time
Exceptions back to the client, and instead send an xml message with some
meaningful error message? do I need to write a custom de-serializer for
this?

Thanks much for any help!

Regards,
Vishy

Re: Schema Validation

Posted by Jeff Greif <je...@gmail.com>.
1.  I believe the XML of the request s already deserialized and parsed 
by the time it reaches any handlers, and is in the form of a DOM.  To 
validate in a handler or in your service implementation you must be able 
either to validate the DOM or, presumably less efficiently, serialize 
back to a string or stream and reparse with validation features enabled.

If you have a recent-enough version of Xerces (such as the latest), you 
can validate a DOM in memory against a schema.  This can be done in a 
handler or or in your service implementation. 

2.  If you control the validation process, you can catch any thrown 
exceptions and do what you want. 


It might be possible to turn on validation in the parser that axis is 
using to deserialize the web service request, but this will just throw 
exceptions back to the client, unless you could also specify the error 
handler for the parser (which might be tricky even if allowed, since you 
still have to meet the constraints of specs Axis implements).  Trying to 
do it this way would also affect all the other axis services in the axis 
webapp, some of which may not need validation of the request or prefer 
to do it themselves.

Jeff

Vishy wrote:
> Hi,
>  
> I am using Axis 1.3
>  
> Can someone point me in the right direction, to accomplish the following?
>  
> 1) Validate incoming/outgoing xml against a schema...the only place, 
> where I am thinking I can do this, is in a request or response 
> handler...am I correct? has anyone done this before?
>  
> 2) How can I avoid throwing IllegalArgumentExceptions or Invalid 
> Date/Time Exceptions back to the client, and instead send an xml 
> message with some meaningful error message? do I need to write a 
> custom de-serializer for this?
>  
> Thanks much for any help!
>  
> Regards,
> Vishy
>