use of org.apache.xmlrpc.client.XmlRpcClient in project camel by apache.
the class XmlRpcEndpoint method createClient.
public XmlRpcClient createClient() throws MalformedURLException {
XmlRpcClient client = new XmlRpcClient();
// setup the client with the configuration from the XmlRpcEndpoint
XmlRpcClientConfigImpl config = clientConfig.cloneMe();
// setup the server url
config.setServerURL(new URL(getAddress()));
client.setConfig(config);
if (clientConfigurer != null) {
clientConfigurer.configureXmlRpcClient(client);
}
return client;
}
use of org.apache.xmlrpc.client.XmlRpcClient in project processdash by dtuma.
the class CCDefectTypeLookup method main.
/**
* Run a simple, standalone test to see if our known strategies work against
* a particular server.
*/
public static void main(String[] args) {
URL baseUrl, url;
try {
baseUrl = new URL(args[0]);
url = new URL(baseUrl, "/xmlrpc/secure");
} catch (IOException ioe) {
throw new RuntimeException("Malformed URL " + args[0]);
}
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setServerURL(url);
config.setBasicUserName(args[1]);
config.setBasicPassword(args[2]);
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
try {
execute(client, "getServerVersion");
} catch (Exception e) {
throw new RuntimeException("Unable to contact server " + baseUrl + " - cannot validate defect lookup strategy");
}
CCDefectTypeLookup lookup = getTypeLookup(client);
String oneType = lookup.getType(1);
if (oneType != null) {
System.out.println("Code Collaborator defect type lookup " + "strategy succeeded against URL " + baseUrl);
return;
} else {
throw new RuntimeException("Code Collaborator defect type lookup " + "strategy failed against URL " + baseUrl);
}
}
use of org.apache.xmlrpc.client.XmlRpcClient in project processdash by dtuma.
the class BoundXmlRpcConnection method openConnectionImpl.
protected XmlRpcClient openConnectionImpl(boolean printException) throws ErrorDataValueException {
String username = null;
String password = null;
try {
// look up the information needed to make the connection
String baseUrl = this.baseUrl.getValue();
String urlSuffix = this.urlSuffix.getValue();
username = getUsername(this.username.getValue());
password = getPassword(this.password.getValue());
URL url = new URL(baseUrl.trim());
if (StringUtils.hasValue(urlSuffix))
url = new URL(url, urlSuffix);
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setServerURL(url);
config.setEnabledForExtensions(true);
if (username != null && password != null) {
config.setBasicUserName(username);
config.setBasicPassword(password);
}
XmlRpcClient connection = new XmlRpcClient();
connection.setConfig(config);
if (StringUtils.hasValue(testMethodName))
connection.execute(testMethodName, Collections.EMPTY_LIST);
if (!validateCredentials(connection, username, password))
throw new ErrorDataValueException(BAD_USERNAME_PASS, ErrorData.SEVERE);
setError(null, ErrorData.NO_ERROR);
return connection;
} catch (MalformedURLException mue) {
throw new ErrorDataValueException(INVALID_URL, ErrorData.SEVERE);
} catch (XmlRpcNotAuthorizedException nae) {
throw getBadCredentialsException(username, password);
} catch (ErrorDataValueException edve) {
throw edve;
} catch (Exception e) {
// we were unable to open a connection; return null.
if (printException)
e.printStackTrace();
return null;
}
}
use of org.apache.xmlrpc.client.XmlRpcClient in project ofbiz-framework by apache.
the class XmlRpcTests method testXmlRpcRequest.
/**
* Test Xml Rpc by java class call with a Object List
* @throws Exception
*/
public void testXmlRpcRequest() throws Exception {
XmlRpcClient client = this.getRpcClient(url, "admin", "ofbiz");
Object[] params = new Object[] { 55.00, "message from xml-rpc client" };
Map<String, Object> result = UtilGenerics.cast(client.execute("testScv", params));
assertEquals("XML-RPC Service result success", "service done", result.get("resp"));
}
use of org.apache.xmlrpc.client.XmlRpcClient in project ovirt-engine by oVirt.
the class ExternalSchedulerBrokerImpl method runBalance.
@Override
public Optional<BalanceResult> runBalance(String balanceName, List<Guid> hostIDs, Map<String, String> propertiesMap) {
try {
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
Object result = client.execute(BALANCE, createBalanceArgs(balanceName, hostIDs, propertiesMap));
return Optional.of(ExternalSchedulerBrokerObjectBuilder.getBalanceResult(result));
} catch (XmlRpcException e) {
log.error("Error communicating with the external scheduler while balancing: {}", e.getMessage());
log.debug("Exception", e);
auditLogFailedToConnect();
return Optional.empty();
}
}
Aggregations