On Friday, October 07, 2011 12:40:23 PM Guy Pardon wrote:
> Hi,
>
> I found a lot of references to this but no clear explanation or solution:
>
> A simple application exception seems mapped to WSDL faults without problems.
> But if I want my jaxws service to throw exceptions of some subclass
> hierarchy, then the WSDL does not reflect that hierarchy in the fault types
> (and the generate client code does not either). They will appear as
> unrelated faults, so the client code cannot use the exception hierarchy for
> dealing with errors in the catch blocks.
>
> Example, if I want the following then what is the right way of doing this in
> JAXWS? And: where is this specified in the specs or docs?
It doesn't look like JAX-WS handles this at all. Exceptions are created from
the Message, not the types of the parts in the message. Since messages don't
have any sort of hierarchy, there isn't a way to create a hierarchy.
:-(
Dan
>
> SERVER:
>
> @WebService
> public class MyService {
>
> public void doIt() throws MyException {
> throw new MySubException();
> }
>
> }
>
> public class MyException extends Exception {
>
> }
>
> public class MySubException extends MyException {
>
> }
>
> CLIENT:
>
> try {
> service.doIt();
> } catch (MySubException specificError) {
> //...
> } catch (MyException generalError) {
> //...
> }
>
> Thanks
> Guy
--
Daniel Kulp
[email protected]
http://dankulp.com/blog
Talend - http://www.talend.com