private XmlRpcClient getXmlClient() { XmlRpcClient client = new XmlRpcClient(); URL url; try { url = new URL("http://" + _ip + ":" + _port.toString()); _config.setTimeZone(TimeZone.getTimeZone("UTC")); _config.setServerURL(url); _config.setReplyTimeout(0); // disable, we use asyncexecute to control timeout _config.setConnectionTimeout(6000); _config.setBasicUserName(_username); _config.setBasicPassword(_password); client.setConfig(_config); } catch (MalformedURLException e) { throw new CloudRuntimeException(e.getMessage()); } return client; }
@Override @SuppressWarnings("unchecked") public Map<String, Object> getLinkInfo(String sender, String receiver) throws XmlRpcException { return (Map<String, Object>) client.execute("getLinkInfo", new Object[]{sender, receiver}); }
/** Performs a request with the clients default configuration. * @param pMethodName The method being performed. * @param pParams The parameters. * @return The result object. * @throws XmlRpcException Performing the request failed. */ public Object execute(String pMethodName, List pParams) throws XmlRpcException { return execute(getClientConfig(), pMethodName, pParams); }
xmlClient.getClientConfig(), method, params); xmlClient.executeAsync(req, callback); return callback.waitForResponse(); } catch (TimingOutCallback.TimeoutException e) {
private XmlRpcClient setupXmlClient() { final XmlRpcClient client = new XmlRpcClient(); client.setConfig(xmlClientConfig); client.setTypeFactory(new RpcTypeFactory(client)); } catch (MalformedURLException e) { LOGGER.info("Incorrect URL: ", e);
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { Object result = null; logger.debug("Invoke : " + clazz.getName() + "." + method.getName() + "(" + Arrays.toString(args) + ")"); logger.debug("XML-RPC , Using uri = http:" + this.serviceLocation); //Le client XMLRPC de crispy est en version < 3 XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); try { config.setServerURL(new URL("http:" + this.serviceLocation)); XmlRpcClient client = new XmlRpcClient(); client .setTransportFactory(new XmlRpcCommonsTransportFactory( client)); client.setConfig(config); result = client.execute(clazz.getName() + "." + method.getName(), args); } catch (java.net.MalformedURLException e) { System.out.println("Caught MalformedURLException\n"); e.printStackTrace(); } catch (XmlRpcException e) { System.out.println("Caught XmlRpcException\n"); e.printStackTrace(); } return result; }
@Override public Map<String, Map<String, String>> getAMs(boolean verbose, URL url) throws Exception { // call the actor registry Map<String, Map<String, String>> amData = null; try { XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); config.setServerURL(url); XmlRpcClient client = new XmlRpcClient(); client.setConfig(config); // get verbose list of the AMs amData = (Map<String, Map<String, String>>)client.execute(GET_AMS, new Object[]{!verbose}); } catch (XmlRpcException e) { throw new Exception("Unable to contact registry " + url + " due to " + e); } return amData; }
private XmlRpcClient getConfiguredClient() { XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); config.setServerURL(cUrl); XmlRpcClient client = new XmlRpcClient(); client.setConfig(config); // set this transport factory for host-specific SSLContexts to work XmlRpcCommonsTransportFactory f = new XmlRpcCommonsTransportFactory(client); client.setTransportFactory(f); return client; }
private XmlRpcClient setupClient(FedAgent a, URL url) throws MalformedURLException { XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); config.setServerURL(url); XmlRpcClient client = new XmlRpcClient(); config.setEnabledForExtensions(true); client.setConfig(config); client.setTypeFactory(new MyTypeFactory(client)); // set this transport factory for host-specific SSLContexts to work XmlRpcCommonsTransportFactory f = new XmlRpcCommonsTransportFactory(client); client.setTransportFactory(f); return client; }
config.setReplyTimeout(WebUtil.getSocketTimeout()); xmlrpc = new XmlRpcClient(); xmlrpc.setConfig(config); xmlrpc.setXmlWriterFactory(new CharSetXmlWriterFactory()); xmlrpc.setTransportFactory(factory);
final XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); config.setServerURL(new URL(url)); final XmlRpcTransportFactory transportFactory = new XmlRpcTransportFactory() { public XmlRpcTransport getTransport() { return new MessageLoggingTransport(client); } }; client = new XmlRpcClient(); client.setTransportFactory(transportFactory); client.setConfig(config);
protected TalkToRegistry() { super(); // We use our own HttpClient with an HttpConnectionManager // configured with timeouts, so we don't block the liveness // thread forever. // Connect timeout, 10 seconds; Read timeout, 5 seconds; Close timeout, 3 seconds. connMgr = new SimpleHttpConnectionManager(true); connMgr.getParams().setConnectionTimeout(10*1000); connMgr.getParams().setSoTimeout(5*1000); connMgr.getParams().setLinger(3); httpClient = new HttpClient(connMgr); // We use XmlRpcCommonsTransportFactory, initialized // using the HttpClient from above, so that SSLContexts // work. xmlrpcClient = new XmlRpcClient(); xmlrpcClientConfig = new XmlRpcClientConfigImpl(); transportFactory = new XmlRpcCommonsTransportFactory(xmlrpcClient); transportFactory.setHttpClient(httpClient); xmlrpcClient.setTransportFactory(transportFactory); // Finally - since the SimpleHttpConnectionManager only // provides one backend HttpConnection, ensure that the // XmlRpcClient only has one backend worker available to // consume it. xmlrpcClient.setMaxThreads(1); }
@Override public void setConfig(XmlRpcClientConfig pConfig) { super.setConfig(pConfig); }
XmlRpcClient client = new XmlRpcClient("http://www.upcdatabase.com/xmlrpc", false); Map<String, String> params = new HashMap<String, String>(); params.put("rpc_key", rpc_key); params.put("ean",upc); HashMap<?,?> token = null; try { token = (HashMap<?, ?>) client.invoke( "lookup", new Object[] { params } ); } catch (XmlRpcException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (XmlRpcFault e) { // TODO Auto-generated catch block e.printStackTrace(); }
public Object callTimeoutInSec(String method, Object[] params, int timeout, boolean debug) throws XmlRpcException { TimingOutCallback callback = new TimingOutCallback(timeout * 1000); Object[] mParams = new Object[params.length + 1]; mParams[0] = method; for (int i = 0; i < params.length; i++) { mParams[i + 1] = params[i]; } if (debug) { /* * some parameters including user password should not be printed in log */ s_logger.debug("Call Ovm agent: " + Coder.toJson(mParams)); } long startTime = System.currentTimeMillis(); _client.executeAsync("OvmDispatch", mParams, callback); try { return callback.waitForResponse(); } catch (TimingOutCallback.TimeoutException to) { throw to; } catch (Throwable e) { throw new XmlRpcException(-2, e.getMessage()); } finally { long endTime = System.currentTimeMillis(); long during = (endTime - startTime) / 1000; // in secs s_logger.debug("Ovm call " + method + " finished in " + String.valueOf(during) + " secs"); } }
public XmlRpcClientConfig getConfig() { return super.getClientConfig(); }
@SuppressWarnings("unchecked") public Map<String, Object> getVersion() throws Exception { Map<String, Object> versionMap = null; setSSLIdentity(); try { XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); //TODO //config.setServerURL(new URL(GUI.getInstance().getSelectedController())); config.setServerURL(new URL(CONTROLLER_URL)); //TODO XmlRpcClient client = new XmlRpcClient(); client.setConfig(config); // set this transport factory for host-specific SSLContexts to work XmlRpcCommonsTransportFactory f = new XmlRpcCommonsTransportFactory(client); client.setTransportFactory(f); // get verbose list of the AMs versionMap = (Map<String, Object>)client.execute(GET_VERSION, new Object[]{}); } catch (MalformedURLException e) { throw new Exception("Please check the SM URL " + CONTROLLER_URL); } catch (XmlRpcException e) { throw new Exception("Unable to contact SM " + CONTROLLER_URL + " due to " + e); } catch (Exception e) { throw new Exception("Unable to contact SM " + CONTROLLER_URL); } return versionMap; }
public static boolean auth(String username, String password) { try { // XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); config.setServerURL(new URL("http://aqexcel.activequant.com/xmlrpc.php")); XmlRpcClient client = new XmlRpcClient(); client.setConfig(config); Object[] params = new Object[] { username, password }; Boolean result = (Boolean) client.execute("wpse39662.login", params); // return result; } catch (Exception ex) { ex.printStackTrace(); return false; } }
private XmlRpcClient client() { if ( this.client == null ) { XmlRpcClientConfigImpl clientConfig = new XmlRpcClientConfigImpl(); clientConfig.setServerURL( url ); client = new XmlRpcClient(); client.setTransportFactory( new XmlRpcAhcTransportFactory( client ) ); client.setConfig( clientConfig ); } return client; }
public AbstractLscXmlRpcClient() { options = new Options(); options.addOption("h", "hosturl", true, "Specify the XML RPC server URL"); options.addOption("u", "username", true, "Specify the username"); options.addOption("p", "password", true, "Specify the password"); client = new XmlRpcClient(); }