Yes this worked.  Thanks.

On Tue, Jun 30, 2009 at 9:22 AM, Sergey Beryozkin <[email protected]>wrote:

>
>> 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?
>>
>
> Yes, sure. JAXBExceptions are wrapped into WebApplicationExceptions but you
> can get to the cause exception, you need to register
> ExceptionMapper<WebApplicationException>. Alternatively, you might want to
> register a ValidationEventHandler instance  with JAXBElementProvider and
> when it's notified of the validation issues you can then throw some custom
> CustomValidationException and register
> ExceptionMapper<CustomValidationException>, you can register
> ValidationEventHandler as a 'validationEventHandler' property on
> org.apache.cxf.jaxrs.providers.JAXBElementProvider.
>
> Does it help ?
>
> Sergey
>
>
>
>>
>>
>>
>>
>>> 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?
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>

Reply via email to