Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I found out that by using apache xml-rpc implementation on both client and server it is possible to throw custom exceptions from the server and receive them on the client. Something just needs to be added to the server and client configuration.</p> <p>Server:</p> <pre><code>WebServer server = new WebServer(80); XmlRpcServer xmlRpcServer = server.getXmlRpcServer(); PropertyHandlerMapping phm = new PropertyHandlerMapping(); phm.addHandler("test", JavaServer.class); xmlRpcServer.setHandlerMapping(phm); XmlRpcServerConfigImpl serverConfig = (XmlRpcServerConfigImpl) xmlRpcServer.getConfig(); serverConfig.setEnabledForExceptions(true); serverConfig.setEnabledForExtensions(true); //Add this line server.start(); </code></pre> <p>Client:</p> <pre><code>XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); try { config.setServerURL(new URL("http://localhost:80")); config.setEnabledForExceptions(true); config.setEnabledForExtensions(true); //Add this line XmlRpcClient client = new XmlRpcClient(); client.setConfig(config); Object[] params = new Object[] { new Integer(11), new Integer(3), }; Integer result = (Integer) client.execute(config,"test.sum", params); System.out.println("Results " + result); } catch (XmlRpcException exception) { System.out.println(exception.getMessage()); Throwable cause = exception.getCause(); if(cause != null) { if(cause instanceof MyException) { System.out.println(((MyException)cause).getMessage()); } else { System.out.println("Cause not instance of Exception."); } } else { System.out.println("Cause was null."); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); </code></pre> <p>Then everything works as expected.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload