本文整理汇总了Java中org.apache.xmlrpc.client.XmlRpcClient类的典型用法代码示例。如果您正苦于以下问题:Java XmlRpcClient类的具体用法?Java XmlRpcClient怎么用?Java XmlRpcClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XmlRpcClient类属于org.apache.xmlrpc.client包,在下文中一共展示了XmlRpcClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerUser
import org.apache.xmlrpc.client.XmlRpcClient; //导入依赖的package包/类
public boolean registerUser(String user, String password) throws Exception {
XmlRpcClientConfigImpl xmlConfig = new XmlRpcClientConfigImpl();
xmlConfig.setServerURL(new URL(config.getProperty(SYSTEM_XMPP_BACKEND_SERVER_URL)));
XmlRpcClient client = new XmlRpcClient();
client.setConfig(xmlConfig);
Map<String, Object> params = new HashMap<>();
params.put(USER, user);
params.put(PASSWORD, password);
params.put(SERVER, config.getProperty(SYSTEM_XMPP_DOMAIN));
List<Object> register_params = new ArrayList<>();
register_params.add(params);
Object result = client.execute(CREATE_ACCOUNT, register_params);
return true;
}
示例2: createXmlRpcClient
import org.apache.xmlrpc.client.XmlRpcClient; //导入依赖的package包/类
private XmlRpcClient createXmlRpcClient() {
// create client configuration
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
try {
config.setServerURL(new URL(url));
} catch (MalformedURLException e) {
e.printStackTrace();
Starter.die("could not parse URL");
}
config.setBasicUserName(username);
config.setBasicPassword(password);
// ignore self-signed certificate errors
if (url.startsWith("https")) {
disableCertCheck();
}
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
return client;
}
示例3: getXmlClient
import org.apache.xmlrpc.client.XmlRpcClient; //导入依赖的package包/类
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;
}
示例4: testConnection
import org.apache.xmlrpc.client.XmlRpcClient; //导入依赖的package包/类
private static boolean testConnection(DemoDbInfo infos) {
// Try to connect to that DB to check it is still available
final XmlRpcClient client = new XmlRpcClient();
final XmlRpcClientConfigImpl common_config = new XmlRpcClientConfigImpl();
try {
String protocolAsString = infos.protocol == RPCProtocol.RPC_HTTP ? "http://" : "https://";
common_config.setServerURL(
new URL(String.format("%s%s:%s/xmlrpc/2/common", protocolAsString, infos.host, infos.port)));
int uid = (int) client.execute(common_config, "authenticate",
new Object[] { infos.db, infos.username, infos.password, new Object[] {} });
// Informations are valid if user could log in.
return uid != 0;
} catch (MalformedURLException e1) {
// Previously saved data is causing this...
// We will have to request a new demo db
return false;
} catch (XmlRpcException e) {
// Connection to previous demo db failed somehow, we will have
// to request a new one...
return false;
}
}
示例5: getTrackerError
import org.apache.xmlrpc.client.XmlRpcClient; //导入依赖的package包/类
@Override
public String getTrackerError() {
XmlRpcClient client = initializeClient();
if (client == null) {
return null;
}
String loginStatus = login(client);
if (loginStatus == null) {
return null;
}
// TODO Pass this information back to the user
if (loginStatus.equals(LOGIN_FAILURE)
|| loginStatus.equals(BAD_CONFIGURATION)) {
return "Bugzilla login failed, check your credentials.";
}
if (!projectExists(projectName, client)) {
return "The project specified does not exist - please specify a different"
+ " one or create " + projectName + " in Bugzilla.";
}
return null;
}
示例6: initializeClient
import org.apache.xmlrpc.client.XmlRpcClient; //导入依赖的package包/类
/**
* Set up the configuration
*
* @return
* @throws MalformedURLException
*/
private XmlRpcClient initializeClient() {
// Get the RPC client set up and ready to go
// The alternate TransportFactory stuff is required so that cookies
// work and the logins behave persistently
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
try {
config.setServerURL(new URL(this.getServerURLWithRpc()));
} catch (MalformedURLException e) {
e.printStackTrace();
}
// config.setEnabledForExtensions(true);
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
XmlRpcCommonsTransportFactory factory = new XmlRpcCommonsTransportFactory(client);
factory.setHttpClient(new HttpClient());
client.setTransportFactory(factory);
return client;
}
示例7: main
import org.apache.xmlrpc.client.XmlRpcClient; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setEnabledForExtensions(true);
config.setServerURL(new URL("http://127.0.0.1:" + Constants.XMLRPC_PORT));
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
String strUserId = "159a1286-33df-4453-bf80-cff4af0d97b0";
String strFolderName = "folder1";
String strParentId = "null";
Object[] params = new Object[] { strUserId, strFolderName, strParentId};
long startTotal = System.currentTimeMillis();
String strResponse = (String) client.execute("XmlRpcSyncHandler.createFolder", params);
System.out.println("Response --> " + Constants.PrettyPrintJson(strResponse));
long totalTime = System.currentTimeMillis() - startTotal;
System.out.println("Total level time --> " + totalTime + " ms");
}
示例8: main
import org.apache.xmlrpc.client.XmlRpcClient; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setEnabledForExtensions(true);
config.setServerURL(new URL("http://127.0.0.1:" + Constants.XMLRPC_PORT));
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
Object[] params = new Object[] { Constants.USER, Constants.REQUESTID, "-4573748213815439639"};
// strFileId
long startTotal = System.currentTimeMillis();
String strResponse = (String) client.execute("XmlRpcSyncHandler.deleteMetadataFile", params);
System.out.println("Response --> " + Constants.PrettyPrintJson(strResponse));
long totalTime = System.currentTimeMillis() - startTotal;
System.out.println("Total level time --> " + totalTime + " ms");
}
示例9: main
import org.apache.xmlrpc.client.XmlRpcClient; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setEnabledForExtensions(true);
config.setServerURL(new URL("http://127.0.0.1:" + Constants.XMLRPC_PORT));
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
Object[] params = new Object[] { Constants.USER, Constants.REQUESTID, "887611628764801051", "2"};
// strFileId, strVersion
long startTotal = System.currentTimeMillis();
String strResponse = (String) client.execute("XmlRpcSyncHandler.restoreMetadata", params);
System.out.println("Response --> " + Constants.PrettyPrintJson(strResponse));
long totalTime = System.currentTimeMillis() - startTotal;
System.out.println("Total level time --> " + totalTime + " ms");
}
示例10: main
import org.apache.xmlrpc.client.XmlRpcClient; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setEnabledForExtensions(true);
config.setServerURL(new URL("http://127.0.0.1:" + Constants.XMLRPC_PORT));
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
String[] chunks = new String[] {"1111", "2222", "3333"};
Object[] params = new Object[] { Constants.USER, Constants.REQUESTID, "test.txt", "", "", "111111", "10", "Text", chunks};
// strFileName, strParentId, strOverwrite, strChecksum, strFileSize,
// strMimetype, strChunks
long startTotal = System.currentTimeMillis();
String strResponse = (String) client.execute("XmlRpcSyncHandler.putMetadataFile", params);
System.out.println("Response --> " + Constants.PrettyPrintJson(strResponse));
long totalTime = System.currentTimeMillis() - startTotal;
System.out.println("Total level time --> " + totalTime + " ms");
}
示例11: main
import org.apache.xmlrpc.client.XmlRpcClient; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setEnabledForExtensions(true);
config.setServerURL(new URL("http://127.0.0.1:" + Constants.XMLRPC_PORT));
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
String strUserId = "159a1286-33df-4453-bf80-cff4af0d97b0";
String strItemId = "100";
String strIncludeList = "true";
String strIncludeDeleted = "true";
String strIncludeChunks = "true";
String strVersion = "null";
Object[] params = new Object[] { strUserId, strItemId, strIncludeList, strIncludeDeleted, strIncludeChunks, strVersion};
long startTotal = System.currentTimeMillis();
String strResponse = (String) client.execute("XmlRpcSyncHandler.getMetadata", params);
System.out.println("Response --> " + Constants.PrettyPrintJson(strResponse));
long totalTime = System.currentTimeMillis() - startTotal;
System.out.println("Total level time --> " + totalTime + " ms");
}
示例12: main
import org.apache.xmlrpc.client.XmlRpcClient; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setEnabledForExtensions(true);
config.setServerURL(new URL("http://127.0.0.1:" + Constants.XMLRPC_PORT));
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
Object[] params = new Object[] { Constants.USER, Constants.REQUESTID, "hola5", null};
// strFolderName, strParentId
long startTotal = System.currentTimeMillis();
String strResponse = (String) client.execute("XmlRpcSyncHandler.putMetadataFolder", params);
System.out.println("Response --> " + Constants.PrettyPrintJson(strResponse));
long totalTime = System.currentTimeMillis() - startTotal;
System.out.println("Total level time --> " + totalTime + " ms");
}
示例13: main
import org.apache.xmlrpc.client.XmlRpcClient; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setEnabledForExtensions(true);
config.setServerURL(new URL("http://127.0.0.1:" + Constants.XMLRPC_PORT));
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
Object[] params = new Object[] { Constants.USER, Constants.REQUESTID, "887611628764801051" };
// strFileId
long startTotal = System.currentTimeMillis();
String strResponse = (String) client.execute("XmlRpcSyncHandler.getVersions", params);
System.out.println("Response --> " + Constants.PrettyPrintJson(strResponse));
long totalTime = System.currentTimeMillis() - startTotal;
System.out.println("Total level time --> " + totalTime + " ms");
}
示例14: initializeRPC
import org.apache.xmlrpc.client.XmlRpcClient; //导入依赖的package包/类
public static void initializeRPC(String user, String password,String port){
try{XmlRpcClientConfigImpl configuration = new XmlRpcClientConfigImpl();
configuration.setBasicPassword(password);
configuration.setBasicUserName(user);
configuration.setServerURL(new URL("http://"+user+":"+password+"@"+MainRepository.host+
":"+port+"/"));
client = new XmlRpcClient();
client.setConfig(configuration);
System.out.println("Client initialized: "+client);
if(!isCE()){
CustomDialog.showInfo(JOptionPane.WARNING_MESSAGE,applet,
"Warning", "CE is not running, please start CE in "+
"order for Twister Framework to run properly");
return;
}
loadPlugin("ControlPanel");
}
catch(Exception e){
e.printStackTrace();
System.out.println("Could not conect to "+
MainRepository.host+" :"+port+
"for RPC client initialization");
}
}
示例15: initializeRPC
import org.apache.xmlrpc.client.XmlRpcClient; //导入依赖的package包/类
public void initializeRPC() {
try {
XmlRpcClientConfigImpl configuration = new XmlRpcClientConfigImpl();
configuration.setServerURL(new URL("http://"
+ variables.get("host") + ":"
+ variables.get("centralengineport")));
configuration.setBasicPassword(variables.get("password"));
configuration.setBasicUserName(variables.get("user"));
client = new XmlRpcClient();
client.setConfig(configuration);
System.out.println("Client initialized: " + client);
} catch (Exception e) {
System.out.println("Could not conect to " + variables.get("host")
+ " :" + variables.get("centralengineport")
+ "for RPC client initialization");
}
}