On Tue, Jun 30, 2009 at 7:33 AM, Sergey Beryozkin <[email protected]>wrote:
> Hi > > > Thanks Sergey >> >> Can you give me an example? Do i just add a <bean id="" class="" /> of >> my >> ExceptionMapper implementation? >> >> <jaxrs:providers> >> ..... >> </jaxrs:providers> >> >> yes, exactly, or you can link to beans defined outside of > jaxrs:providers, can be hamdy when you want to configure your providers > somehow : > > http://cwiki.apache.org/CXF20DOC/jax-rs.html#JAX-RS-Registeringcustomproviders > > > >> >> >> I saw the validation example, but i was wondering how i can have at the >> validator so i can massage the Response going back to the caller. >> > > Can you clarify a bit more ? Would you like your ExceptionMapper to produce > a custom Response if the validation error occurs ? > Let me give a little background....i have a client passing XML to my JAX-RS service. I am using JAXB bindings. I appended some extra characters to the XML which i sent the service to see how it would error, in particular what the client would get as a response. The client got a JAXBException of some sort...can not remember from yesterday afternoon ;). If i register an ExceptionMapper for JAXBException or any of the XML Validation exceptions i see, would that allow me to make a custom error message to send back to the caller? > > cheers, Sergey > > > >> >> >> >> On Tue, Jun 30, 2009 at 5:35 AM, Sergey Beryozkin <[email protected] >> >wrote: >> >> Hi, >>> >>> You can register an exception mapper as a provider from Spring, inside a >>> jaxrs:providers tag. >>> >>> As far as the validation is concerned, here is how you can do it : >>> >>> >>> http://cwiki.apache.org/CXF20DOC/jax-rs.html#JAX-RS-Schemavalidationsupport >>> >>> You can also inject an instance of ValidationEventHandler into a JAXB >>> provider. >>> Or you can get more control by registering a custom XMLStreamReader and >>> do >>> some schematron-like validation in there...and throw some exception from >>> there....Let me know please if you'd like some more info on this last >>> option. >>> >>> cheers, Sergey >>> >>> >>> ----- Original Message ----- From: "Nathaniel Auvil" < >>> [email protected]> >>> To: <[email protected]> >>> Sent: Tuesday, June 30, 2009 2:57 AM >>> Subject: JAX-RS Exception Handlers and Validation >>> >>> >>> >>> I am looking at how to get validations and exception handling going. >>> >>>> Right >>>> now i send some garbage XML in and it throws a JAXException back in the >>>> response. I would prefer to be able to handle this back on the serve >>>> and >>>> give the client a less specific error. >>>> >>>> I am using Spring to configure things and i did not see anything in the >>>> examples which shows me how to add an exception handler or how to get >>>> control of the XML Validations. Can anyone point me in the right >>>> direction? >>>> >>>> >>>> >>> >> >
