[jboss-user] [JBossWS] - WebFault and Declared RuntimeException is wrapped by SOAPFau

skajotde do-not-reply at jboss.com
Thu Apr 16 09:15:55 EDT 2009


Hi All !

I'm writing webservice with JBoss 4.2.3 and jbossws-native-3.0.3.GA. When I declare checked exception, client can catch right unbinded exception.

    @WebMethod
  |     public String testWyjatek003(@WebParam(name = "paramString") String paramString) throws WyjatekTestowy,
  |             WyjatekTestowyDziedziczacy;

When I declare runtime exception, exception is right unmarshalled as cause of SOAPFaultException but is not unwrapped.

  |     @WebMethod
  |     public String testWyjatekRuntime005(@WebParam(name = "paramString") String paramString)
  |             throws WyjatekTestowyRuntime02;
  | 
  |     @WebFault
  |     @ApplicationException(rollback = true)
  |     public class WyjatekTestowyRuntime02 extends RuntimeException {
  |         [...]
  |     }
  | 

I was investigating this case and I found ClientProxy.handleException(Exception ex)

   private void handleException(Exception ex) throws Throwable
  |    {
  |       if (ex instanceof SOAPFaultException)
  |       {
  |          // Unwrap the cause if it is an Application Exception, otherwise use a protocol exception
  |          Throwable cause = ex.getCause();
  |          if (cause instanceof Exception)
  |          {
  |             // Throw unwrapped WebServiceException
  |             if (cause instanceof WebServiceException)
  |                throw (WebServiceException)cause;
  | 
  |             // Throw wrapped SOAPException
  |             if (cause instanceof SOAPException)
  |                throw (SOAPFaultException)ex;
  | 
  |             // Throw wrapped RuntimeException
  |             if (cause instanceof RuntimeException)
  |                throw (SOAPFaultException)ex;
  | 
  |             // Throw all other causes
  |             throw (Exception)cause;
  |          }
  |       }
  |       throw ex;
  |    }

So RuntimeException is wrapped with SOAPFaultException. 

Is there way to write transparent code with declaring RuntimException and services with JBossWS ?

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4225916#4225916

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4225916



More information about the jboss-user mailing list