users@glassfish.java.net

How to throw a SOAPFaultException in a WebMethod implemented in an EJB

From: Vincent Deschênes <vdeschenes_at_stelvio.com>
Date: Thu, 11 Mar 2010 16:35:37 -0500

I am trying to throw a SOAPFaultException from a web service implemented on an EJB.

 

If a simply throw new SOAPFaultException(…)

 

I get this SoapFault

 

      <S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope">

         <faultcode>S:Server</faultcode>

         <faultstring>javax.ejb.EJBException</faultstring>

      </S:Fault>

Which describe an javax.ejb.EJBException which is caused by me throwing my SOAPFaultException. I can see it if I enable the
stacktrace in the exception.

If I disable the stack trace I always get this EJBException and I have no way to set an error message.

 

Anyone has a solution ?

 

I am using glassfish V3.

 

Thanks.

 

Vincent Deschenes