
Untitled
By: a guest on
Apr 26th, 2012 | syntax:
None | size: 1.76 KB | hits: 17 | expires: Never
JAX-RPC client can handle checked exception
public interface CalcPort extends java.rmi.Remote {
/**
* Operation Name : {http://local/ws/calc}sum */
public int sum(int x,int y) throws java.rmi.RemoteException, local.ws.calc.CalculationError;
}
int result = 0;
try {
result = calc.sum(-10, 20);
} catch (CalculationError e)
{
// we should be here if negative "x" is used
}
<soapenv:Fault>
<faultcode>soapenv:Server</faultcode>
<faultstring/>
<detail>
<tra:calculationError xmlns:tra="http://local/ws/calc">
<tra:code>1</tra:code>
</tra:calculationError>
</detail>
</soapenv:Fault>
public int sum(int x,int y) throws java.rmi.RemoteException, com.netcracker.ws.training.CalculationError {
java.util.ArrayList _args = new java.util.ArrayList();
_args.add(new Integer(x));
_args.add(new Integer(y));
try {
java.lang.Object _result = _invoke("sum", _args.toArray());
return ((java.lang.Integer)_result).intValue();
} catch (javax.xml.rpc.JAXRPCException _wls_exception) {
throw new java.rmi.RemoteException(_wls_exception.getMessage(), _wls_exception.getLinkedCause());
} catch (javax.xml.rpc.soap.SOAPFaultException _wls_exception) {
System.out.println("WE ARE HERE!!!");
throw new java.rmi.RemoteException(_soapFault2String(_wls_exception), _wls_exception);
} catch (java.lang.Throwable _wls_exception) {
System.out.println("BUT SHOULD BE HERE!!!");
if (_wls_exception instanceof com.netcracker.ws.training.CalculationError) throw (com.netcracker.ws.training.CalculationError)_wls_exception;
throw new java.rmi.RemoteException(_wls_exception.getMessage(), _wls_exception);
}
}