cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kulp <dk...@apache.org>
Subject Re: Unchecked exception handling
Date Mon, 05 Nov 2007 21:07:13 GMT


Jeff,

There might be an easier way to do it.   If you subclass the JaxWsServiceFactoryBean and override
the 

 protected void initializeFaults(final InterfaceInfo service,
               final OperationInfo op, final Method method)

call, you could have the faults automatically added into the service model at service creation
time.   Thus, they would properly appear in the wsdl and the runtime should be able to marshal/unmarshall
it normally.   You would just need to use your ServiceFactory instead of ours.

Dan


On Friday 02 November 2007, Jeff Moroski wrote:
> I have a need (a perceived need at least) to be able to throw
> unchecked exceptions from a web service method.
>
> For instance, a call to a method saveCategory(dto) could throw an
> EntityNotFoundException, a ValidationException, an
> InsufficientRightsException, a DataAccessException, etc.
>
> Rather than make these all checked exceptions and have to catch and
> throw at all the various layers (to handle things like auditing and
> transaction rollback and license revocations) I'd like to define the
> saveCategory method to throw these unchecked exceptions.  I realize
> that unchecked exceptions don't have to go in the throws clause, but
> it is a quick and easy way to get the exceptions into the wsdl.
>
> I know that web services aren't supposed to play well with
> RuntimeExceptions, but why couldn't I create a custom fault handler to
> catch runtime exceptions and wrap a checked exception around it?  That
> way the saveCategory method can stay readable (as well as the manager
> and DAO layers), and CXF can still send back a checked exception.



-- 
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog
Mime
  • Unnamed multipart/alternative (inline, 7-Bit, 0 bytes)
View raw message