public HomeMaticClient(String urlString) throws IOException { URL url = new URL(urlString); XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); config.setServerURL(url); config.setEnabledForExtensions(true); config.setEncoding("ISO-8859-1"); //only used in modified XmlRpcStreamTransport config.setEnabledForExceptions(true); client = new XmlRpcClient(); client.setConfig(config); this.logger = LoggerFactory.getLogger(getClass().getCanonicalName() + "-" + url.getHost()); }
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();
config.setBasicPassword(password.trim()); config.setEnabledForExceptions(true);
private XmlRpcClient getXmlRpcClient( URL url, ConnectionInfo connectionInfo ) { XmlRpcClientConfigImpl clientConfig = new XmlRpcClientConfigImpl(); clientConfig.setServerURL( url ); clientConfig.setEnabledForExceptions( true ); if ( connectionInfo != null ) { clientConfig.setBasicUserName( connectionInfo.getUsername() ); clientConfig.setBasicPassword( connectionInfo.getPassword() ); clientConfig.setBasicEncoding( connectionInfo.getEncoding() ); clientConfig.setGzipCompressing( connectionInfo.isGzip() ); clientConfig.setGzipRequesting( connectionInfo.isGzip() ); clientConfig.setReplyTimeout( connectionInfo.getTimeout() ); clientConfig.setConnectionTimeout( connectionInfo.getTimeout() ); clientConfig.setTimeZone( connectionInfo.getTimeZone() ); } final XmlRpcClient client = new XmlRpcClient(); client.setTypeFactory( new BinderTypeFactory( client ) ); XmlRpcCommonsTransportFactory factory = new XmlRpcCommonsTransportFactory( client ); // Alternative - use simple connection manager, but make sure it closes the connection each time // This would be set here since it would not be thread-safe // factory.setHttpClient( new HttpClient( new SimpleHttpConnectionManager( true ) ) ); factory.setHttpClient( httpClient ); client.setConfig( clientConfig ); return client; }
xmlRpcClientConfig.setEnabledForExceptions(appConfig.getBoolean(XMLRPC_ENABLED_FOR_EXCEPTIONS)); } catch (ConversionException ce) { this.debug(ce);