You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Kaleb Walton <kd...@us.ibm.com> on 2007/09/18 21:23:47 UTC

Specifying an exception as a WebFault using Simple Server (simple:server)


Exceptions that I throw are not rendered as Fault's to web service clients
even after specifying WebFault annotations on the Exception class. I can
see the ServiceException in the WSDL but the methods themselves are just
ignoring the fact that I'm throwing exceptions. Can anyone point me in the
right direction?

I have an exception defined as follows:

@WebFault(name="ServiceFault")
public class ServiceException extends Exception {
  // Custom Exception Implementation
}


I'm using Spring to configure a simple:server:

<simple:server id="myServer" serviceClass="a.b.c.MyService"
serviceBean="#myService" address="/MyService"/>


I'm throwing ServiceExceptions on each method in MyService:

class MyService {
  public ServiceResult find(ServiceArg arg) throws ServiceException {
    // do stuff
  }
}

Regards,
Kaleb

Re: Specifying an exception as a WebFault using Simple Server (simple:server)

Posted by Kaleb Walton <kd...@us.ibm.com>.
Ok got a bit further - this was in the debug logs:

org.apache.cxf.interceptor.Fault: Marshalling Error: a.b.c.ServiceException
is not known to this context

At least that takes me one step further - if anyone has a quick answer I'd
appreciate it. I'll post my solution when it's found.

Regards,
Kaleb


|------------>
| From:      |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Kaleb Walton/Southfield/IBM@IBMUS                                                                                                                 |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| To:        |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |cxf-user@incubator.apache.org                                                                                                                     |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Date:      |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |09/18/2007 03:24 PM                                                                                                                               |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Subject:   |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Specifying an exception as a WebFault using Simple Server (simple:server)                                                                         |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|







Exceptions that I throw are not rendered as Fault's to web service clients
even after specifying WebFault annotations on the Exception class. I can
see the ServiceException in the WSDL but the methods themselves are just
ignoring the fact that I'm throwing exceptions. Can anyone point me in the
right direction?

I have an exception defined as follows:

@WebFault(name="ServiceFault")
public class ServiceException extends Exception {
  // Custom Exception Implementation
}


I'm using Spring to configure a simple:server:

<simple:server id="myServer" serviceClass="a.b.c.MyService"
serviceBean="#myService" address="/MyService"/>


I'm throwing ServiceExceptions on each method in MyService:

class MyService {
  public ServiceResult find(ServiceArg arg) throws ServiceException {
    // do stuff
  }
}

Regards,
Kaleb

Re: Specifying an exception as a WebFault using Simple Server (simple:server)

Posted by Daniel Kulp <dk...@apache.org>.

The issue is that @WebFault annotation is a JAX-WS frontend thing.   
Thus, the simple frontend doesn't try to process it at all.

You MAY be able to get it to work by adding the WebFaultOutInterceptor 
from the jax-ws package onto your out fault interceptor chain.  

Dan




On Tuesday 18 September 2007, Kaleb Walton wrote:
> Exceptions that I throw are not rendered as Fault's to web service
> clients even after specifying WebFault annotations on the Exception
> class. I can see the ServiceException in the WSDL but the methods
> themselves are just ignoring the fact that I'm throwing exceptions.
> Can anyone point me in the right direction?
>
> I have an exception defined as follows:
>
> @WebFault(name="ServiceFault")
> public class ServiceException extends Exception {
>   // Custom Exception Implementation
> }
>
>
> I'm using Spring to configure a simple:server:
>
> <simple:server id="myServer" serviceClass="a.b.c.MyService"
> serviceBean="#myService" address="/MyService"/>
>
>
> I'm throwing ServiceExceptions on each method in MyService:
>
> class MyService {
>   public ServiceResult find(ServiceArg arg) throws ServiceException {
>     // do stuff
>   }
> }
>
> Regards,
> Kaleb



-- 
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog