Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 26th, 2012  |  syntax: None  |  size: 1.76 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. JAX-RPC client can handle checked exception
  2. public interface CalcPort extends java.rmi.Remote {
  3.  
  4.   /**
  5.    * Operation Name : {http://local/ws/calc}sum   */
  6.  
  7.   public int sum(int x,int y) throws java.rmi.RemoteException, local.ws.calc.CalculationError;
  8.  
  9. }
  10.        
  11. int result = 0;
  12. try {
  13.    result = calc.sum(-10, 20);
  14. } catch (CalculationError e)
  15. {
  16.    // we should be here if negative "x" is used                  
  17. }
  18.        
  19. <soapenv:Fault>
  20.   <faultcode>soapenv:Server</faultcode>
  21.   <faultstring/>
  22.   <detail>
  23.      <tra:calculationError xmlns:tra="http://local/ws/calc">
  24.           <tra:code>1</tra:code>
  25.      </tra:calculationError>
  26.   </detail>
  27. </soapenv:Fault>
  28.        
  29. public int sum(int x,int y) throws java.rmi.RemoteException, com.netcracker.ws.training.CalculationError {
  30.         java.util.ArrayList _args = new java.util.ArrayList();
  31.         _args.add(new Integer(x));
  32.         _args.add(new Integer(y));
  33.  
  34.         try {
  35.                 java.lang.Object _result = _invoke("sum", _args.toArray());
  36.           return ((java.lang.Integer)_result).intValue();
  37.         } catch (javax.xml.rpc.JAXRPCException _wls_exception) {
  38.           throw new java.rmi.RemoteException(_wls_exception.getMessage(), _wls_exception.getLinkedCause());
  39.         } catch (javax.xml.rpc.soap.SOAPFaultException _wls_exception) {
  40.           System.out.println("WE ARE HERE!!!");
  41.           throw new java.rmi.RemoteException(_soapFault2String(_wls_exception), _wls_exception);
  42.         } catch (java.lang.Throwable _wls_exception) {
  43.           System.out.println("BUT SHOULD BE HERE!!!");
  44.           if (_wls_exception instanceof com.netcracker.ws.training.CalculationError) throw (com.netcracker.ws.training.CalculationError)_wls_exception;
  45.  
  46.           throw new java.rmi.RemoteException(_wls_exception.getMessage(), _wls_exception);
  47.         }
  48. }