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()); }
public Confluence(String endpoint) throws MalformedURLException { if (endpoint.endsWith("/")) { endpoint = endpoint.substring(0, endpoint.length() - 1); } if (!endpoint.endsWith("/rpc/xmlrpc")) { endpoint += "/rpc/xmlrpc"; } XmlRpcClientConfigImpl clientConfig = new XmlRpcClientConfigImpl(); clientConfig.setServerURL(new URL(endpoint)); clientConfig.setEnabledForExtensions(true); client = new XmlRpcClient(); client.setTransportFactory( new XmlRpcAhcTransportFactory(client) ); client.setConfig(clientConfig); }
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();
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); config.setServerURL(new URL("http://" + host + ":" + port + "/xmlrpc")); config.setEnabledForExtensions(true); config.setConnectionTimeout(60*1000); config.setReplyTimeout(60*1000);
@Override public void connect() throws CommandException { if (isEmulationEnabled()) return; installDumbTrust(); config = new XmlRpcClientConfigImpl(); config.setBasicUserName(uid); config.setBasicPassword(passwd); try { config.setServerURL(new URL(url)); } catch (MalformedURLException e) { // e.printStackTrace(); logger.error("FlowVisorDevice: unable to connect to " + url + " user " + uid + " pass " + passwd + " due to URL problem " + e.getMessage()); throw new CommandException(e.getMessage()); } catch (Exception e) { logger.error("FlowVisorDevice: unable to connect to " + url + " user " + uid + " pass " + passwd + " due to exception " + e.getMessage()); throw new CommandException(e.getMessage()); } config.setEnabledForExtensions(true); client = new XmlRpcClient(); client.setConfig(config); }
protected Confluence(String endpoint, ConfluenceProxy proxyInfo ) throws URISyntaxException, MalformedURLException { this(new XmlRpcClient()); if (endpoint.endsWith("/")) { endpoint = endpoint.substring(0, endpoint.length() - 1); } endpoint = ConfluenceService.Protocol.XMLRPC.addTo(endpoint); final java.net.URI serviceURI = new java.net.URI(endpoint); XmlRpcClientConfigImpl clientConfig = new XmlRpcClientConfigImpl(); clientConfig.setServerURL(serviceURI.toURL() ); clientConfig.setEnabledForExtensions(true); // add this to support attachment upload client.setConfig( clientConfig ); if( isProxyEnabled(proxyInfo, serviceURI) ) { final XmlRpcCommonsTransportFactory transportFactory = new XmlRpcCommonsTransportFactory( client ); final HttpClient httpClient = new HttpClient(); final HostConfiguration hostConfiguration = httpClient.getHostConfiguration(); hostConfiguration.setProxy( proxyInfo.host, proxyInfo.port ); hostConfiguration.setHost(serviceURI.getHost(), serviceURI.getPort(), serviceURI.toURL().getProtocol()); if( !isNullOrEmpty(proxyInfo.userName) && !isNullOrEmpty(proxyInfo.password) ) { Credentials cred = new UsernamePasswordCredentials(proxyInfo.userName,proxyInfo.password); httpClient.getState().setProxyCredentials(AuthScope.ANY, cred); } transportFactory.setHttpClient( httpClient ); client.setTransportFactory( transportFactory ); } } // Would have been nicer to have a constructor with clientConfig and optionally a transport
protected Confluence(String endpoint, ConfluenceProxy proxyInfo ) throws URISyntaxException, MalformedURLException { this(new XmlRpcClient()); if (endpoint.endsWith("/")) { endpoint = endpoint.substring(0, endpoint.length() - 1); } endpoint = ConfluenceService.Protocol.XMLRPC.addTo(endpoint); final java.net.URI serviceURI = new java.net.URI(endpoint); XmlRpcClientConfigImpl clientConfig = new XmlRpcClientConfigImpl(); clientConfig.setServerURL(serviceURI.toURL() ); clientConfig.setEnabledForExtensions(true); // add this to support attachment upload client.setConfig( clientConfig ); if( isProxyEnabled(proxyInfo, serviceURI) ) { final XmlRpcCommonsTransportFactory transportFactory = new XmlRpcCommonsTransportFactory( client ); final HttpClient httpClient = new HttpClient(); final HostConfiguration hostConfiguration = httpClient.getHostConfiguration(); hostConfiguration.setProxy( proxyInfo.host, proxyInfo.port ); hostConfiguration.setHost(serviceURI.getHost(), serviceURI.getPort(), serviceURI.toURL().getProtocol()); if( !isNullOrEmpty(proxyInfo.userName) && !isNullOrEmpty(proxyInfo.password) ) { Credentials cred = new UsernamePasswordCredentials(proxyInfo.userName,proxyInfo.password); httpClient.getState().setProxyCredentials(AuthScope.ANY, cred); } transportFactory.setHttpClient( httpClient ); client.setTransportFactory( transportFactory ); } } // Would have been nicer to have a constructor with clientConfig and optionally a transport
config.setEnabledForExtensions(true); config.setConnectionTimeout(60 * 1000); config.setReplyTimeout(60 * 1000);
public boolean bind() { XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); config.setServerURL(url); if(username != null && password != null) { config.setBasicUserName(username); config.setBasicPassword(password); } config.setEnabledForExtensions(false); config.setGzipCompressing(false); client.setConfig(config); return true; }
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; }
xmlRpcClientConfig.setEnabledForExtensions(true);