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);
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; }
public Object callTimeoutInSec(String method, List<?> params, int timeout, boolean debug) throws XmlRpcException { TimingOutCallback callback = new TimingOutCallback(timeout * 1000); if (debug) { LOGGER.debug("Call Ovm3 agent " + hostName + "(" + hostIp +"): " + method try { XmlRpcClientRequestImpl req = new XmlRpcClientRequestImpl( xmlClient.getClientConfig(), method, params); xmlClient.executeAsync(req, callback); return callback.waitForResponse(); } catch (TimingOutCallback.TimeoutException e) { LOGGER.info("Timeout: ", e); throw new XmlRpcException(e.getMessage()); } catch (XmlRpcException e) { LOGGER.info("XML RPC Exception occured: ", e);
private XmlRpcClient getXmlRpcClient() { if (xmlRpcClient == null) { final XmlRpcClientConfigImpl xmlrpcConfig = new XmlRpcClientConfigImpl(); xmlrpcConfig.setServerURL(url); xmlRpcClient = new XmlRpcClient(); xmlRpcClient.setConfig(xmlrpcConfig); } return xmlRpcClient; }
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 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; }
/** Performs a request with the given configuration. * @param pConfig The request configuration. * @param pMethodName The method being performed. * @param pParams The parameters. * @return The result object. * @throws XmlRpcException Performing the request failed. */ public Object execute(XmlRpcClientConfig pConfig, String pMethodName, List pParams) throws XmlRpcException { return execute(new XmlRpcClientRequestImpl(pConfig, pMethodName, pParams)); }
/** Performs an asynchronous request with the given configuration. * @param pConfig The request configuration. * @param pMethodName The method being performed. * @param pParams The parameters. * @param pCallback The callback being notified when the request is finished. * @throws XmlRpcException Performing the request failed. */ public void executeAsync(XmlRpcClientConfig pConfig, String pMethodName, List pParams, AsyncCallback pCallback) throws XmlRpcException { executeAsync(new XmlRpcClientRequestImpl(pConfig, pMethodName, pParams), pCallback); }
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 XmlRpcTransport getTransport() { XmlRpcSun15HttpTransport transport = new XmlRpcSun15HttpTransport(getClient()); transport.setSSLSocketFactory(getSSLSocketFactory()); transport.setProxy(proxy); return transport; } }
pWriter.write(baos); log.info(baos.toString()); super.writeRequest(pWriter);
/** Creates a new instance. * @param pFactory The factory, which created this transport. */ public XmlRpcCommonsTransport(XmlRpcCommonsTransportFactory pFactory) { super(pFactory.getClient(), userAgent); HttpClient httpClient = pFactory.getHttpClient(); if (httpClient == null) { httpClient = newHttpClient(); } client = httpClient; }
public XmlRpcTransport getTransport() { XmlRpcLite14HttpTransport transport = new XmlRpcLite14HttpTransport(getClient()); transport.setSSLSocketFactory(sslSocketFactory); return transport; } }
@Override protected Map dispatch(String methodcall, Object[] methodparams) throws XmlRpcException, XenAPIException { if (methodcall.equals("session.local_logout") || methodcall.equals("session.slave_local_login_with_password") || methodcall.equals("session.logout") || methodcall.equals("session.login_with_password")) { return super.dispatch(methodcall, methodparams); } try { return super.dispatch(methodcall, methodparams); } catch (Types.SessionInvalid e) { s_logger.debug("Session is invalid for method: " + methodcall + " due to " + e.toString()); removeConnect(_poolUuid); throw e; } catch (XmlRpcClientException e) { s_logger.debug("XmlRpcClientException for method: " + methodcall + " due to " + e.toString()); removeConnect(_poolUuid); throw e; } catch (XmlRpcException e) { s_logger.debug("XmlRpcException for method: " + methodcall + " due to " + e.toString()); removeConnect(_poolUuid); throw e; } catch (Types.HostIsSlave e) { s_logger.debug("HostIsSlave Exception for method: " + methodcall + " due to " + e.toString()); removeConnect(_poolUuid); throw e; } } }
private XmlRpcClient setupXmlClient() { final XmlRpcClient client = new XmlRpcClient(); xmlClientConfig.setTimeZone(TimeZone.getTimeZone("UTC")); xmlClientConfig.setServerURL(url); xmlClientConfig.setReplyTimeout(0); xmlClientConfig.setConnectionTimeout(60000); xmlClientConfig.setReplyTimeout(60 * 15000); if (hostUser != null && hostPass != null) { LOGGER.debug("Setting username " + hostUser); xmlClientConfig.setBasicUserName(hostUser); xmlClientConfig.setBasicPassword(hostPass); xmlClientConfig.setXmlRpcServer(null); client.setConfig(xmlClientConfig); client.setTypeFactory(new RpcTypeFactory(client)); } catch (MalformedURLException e) { LOGGER.info("Incorrect URL: ", e);
private XmlRpcClient getXmlRpcClient() { if (xmlRpcClient == null) { final XmlRpcClientConfigImpl xmlrpcConfig = new XmlRpcClientConfigImpl(); xmlrpcConfig.setServerURL(url); xmlRpcClient = new XmlRpcClient(); xmlRpcClient.setConfig(xmlrpcConfig); } return xmlRpcClient; }
/** Performs a request with the given configuration. * @param pConfig The request configuration. * @param pMethodName The method being performed. * @param pParams The parameters. * @return The result object. * @throws XmlRpcException Performing the request failed. */ public Object execute(XmlRpcClientConfig pConfig, String pMethodName, Object[] pParams) throws XmlRpcException { return execute(new XmlRpcClientRequestImpl(pConfig, pMethodName, pParams)); }
/** Performs an asynchronous request with the given configuration. * @param pConfig The request configuration. * @param pMethodName The method being performed. * @param pParams The parameters. * @param pCallback The callback being notified when the request is finished. * @throws XmlRpcException Performing the request failed. */ public void executeAsync(XmlRpcClientConfig pConfig, String pMethodName, List pParams, AsyncCallback pCallback) throws XmlRpcException { executeAsync(new XmlRpcClientRequestImpl(pConfig, pMethodName, pParams), pCallback); }
/** Performs a request with the given configuration. * @param pConfig The request configuration. * @param pMethodName The method being performed. * @param pParams The parameters. * @return The result object. * @throws XmlRpcException Performing the request failed. */ public Object execute(XmlRpcClientConfig pConfig, String pMethodName, List pParams) throws XmlRpcException { return execute(new XmlRpcClientRequestImpl(pConfig, pMethodName, pParams)); }
/** Performs a request with the given configuration. * @param pConfig The request configuration. * @param pMethodName The method being performed. * @param pParams The parameters. * @return The result object. * @throws XmlRpcException Performing the request failed. */ public Object execute(XmlRpcClientConfig pConfig, String pMethodName, Object[] pParams) throws XmlRpcException { return execute(new XmlRpcClientRequestImpl(pConfig, pMethodName, pParams)); }