Java Code Examples for org.apache.xmlrpc.client.XmlRpcClient

The following are top voted examples for showing how to use org.apache.xmlrpc.client.XmlRpcClient. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: beyondj   File: XmppService.java   View source code 7 votes vote down vote up
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;
    }
 
Example 2
Project: alfresco-repository   File: DefaultBlogIntegrationImplementation.java   View source code 6 votes vote down vote up
/**
 * Executes an XML RPC method
 * 
 * @param url String
 * @param method String
 * @return Object
 */
protected Object execute(String url, String method, List<Object> params)
{
    Object result = null;
    
    try
    {
        XmlRpcClient client = getClient(url);
        result = client.execute(method, params);
    }
    catch (XmlRpcException exception)
    {
        throw new BlogIntegrationRuntimeException("Failed to execute blog action '" + method + "' @ url '" + url + "'", exception);
    }
    
    return result;
}
 
Example 3
Project: beyondj   File: XmppService.java   View source code 6 votes vote down vote up
public Object checkRegistration(String user) 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(SERVER, config.getProperty(SYSTEM_XMPP_DOMAIN));

        List<Object> check_params = new ArrayList<>();
        check_params.add(params);

        return client.execute(CHECK_USERS_REGISTRATION, check_params);
    }
 
Example 4
Project: log4j-appender-jira   File: JIRALog4jAppender.java   View source code 6 votes vote down vote up
private JiraClientContainer getClientContainer() throws MalformedURLException, XmlRpcException {
    final JiraClientContainer clientContainer = new JiraClientContainer();

    LogLog.debug(SIMPLE_NAME + ": Connecting to xml-rpc host on " + url);

    final XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
    config.setServerURL(new URL(url + "/rpc/xmlrpc"));
    clientContainer.client = new XmlRpcClient();
    clientContainer.client.setConfig(config);

    final List params = new ArrayList();
    params.add(username);
    params.add(password);

    LogLog.debug(SIMPLE_NAME + ": Attempting to login to JIRA installation at " + url + " as " + username);

    clientContainer.token = (String) clientContainer.client.execute("jira1.login", params);
    return clientContainer;
}
 
Example 5
Project: Camel   File: MyClientConfigurer.java   View source code 6 votes vote down vote up
@Override
public void configureXmlRpcClient(XmlRpcClient client) {
    // get the configure first
    XmlRpcClientConfigImpl clientConfig = (XmlRpcClientConfigImpl)client.getClientConfig();
    // change the value of clientConfig
    clientConfig.setEnabledForExtensions(true);
    // set the option on the XmlRpcClient
    client.setMaxThreads(10);
}
 
Example 6
Project: triquetrum   File: FlatteningViaXmlRpcTest.java   View source code 6 votes vote down vote up
@BeforeClass
public static void start() throws IOException, XmlRpcException {
  webServer = new WebServer(0);
  XmlRpcServer xmlRpcServer = webServer.getXmlRpcServer();

  PropertyHandlerMapping phm = new PropertyHandlerMapping();

  phm.addHandler("Loopback", LoopbackClass.class);
  xmlRpcServer.setHandlerMapping(phm);

  XmlRpcServerConfigImpl serverConfig = (XmlRpcServerConfigImpl) xmlRpcServer.getConfig();
  serverConfig.setEnabledForExtensions(false);
  serverConfig.setContentLengthOptional(false);

  webServer.start();

  XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
  config.setServerURL(new URL("http://127.0.0.1:" + webServer.getPort() + "/xmlrpc"));
  client = new XmlRpcClient();
  client.setConfig(config);
}
 
Example 7
Project: libelula   File: XmlRpcManager.java   View source code 6 votes vote down vote up
@Override
public String call() throws Exception {
    XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
    config.setConnectionTimeout(cm.getXmlrpcMsTimeOut());
    config.setGzipCompressing(true);
    config.setGzipRequesting(true);
    config.setServerURL(cm.getXmlrpcURI());
    XmlRpcClient client = new XmlRpcClient();
    client.setConfig(config);
    Object objResult = client.execute(method, params);
    String result = "";
    if (objResult instanceof String) {
        result = (String) objResult;
    } else {
        result = result + objResult;
    }
    return result;
}
 
Example 8
Project: libelula   File: XmlRpcManager.java   View source code 6 votes vote down vote up
@Override
public String call() throws Exception {
    XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
    config.setConnectionTimeout(cm.getXmlrpcMsTimeOut());
    config.setGzipCompressing(true);
    config.setGzipRequesting(true);
    config.setServerURL(cm.getXmlrpcURI());
    XmlRpcClient client = new XmlRpcClient();
    client.setConfig(config);
    Object objResult = client.execute(method, params);
    String result = "";
    if (objResult instanceof String) {
        result = (String) objResult;
    } else {
        result = result + objResult;
    }
    return result;
}
 
Example 9
Project: community-edition-old   File: DefaultBlogIntegrationImplementation.java   View source code 6 votes vote down vote up
/**
 * Executes an XML RPC method
 * 
 * @param url String
 * @param method String
 * @return Object
 */
protected Object execute(String url, String method, List<Object> params)
{
    Object result = null;
    
    try
    {
        XmlRpcClient client = getClient(url);
        result = client.execute(method, params);
    }
    catch (XmlRpcException exception)
    {
        throw new BlogIntegrationRuntimeException("Failed to execute blog action '" + method + "' @ url '" + url + "'", exception);
    }
    
    return result;
}
 
Example 10
Project: PiOnWheels   File: Client.java   View source code 6 votes vote down vote up
public POWRemoteAPI connect(String ip) {
    XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
    try {
        config.setServerURL(new URL("http://" + ip + ":" + port + "/xmlrpc"));
    } catch (MalformedURLException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }

    XmlRpcClient client = new XmlRpcClient();
    client.setConfig(config);

    ClientFactory factory = new ClientFactory(client);
    POWRemoteAPI api = (POWRemoteAPI) factory.newInstance(POWRemoteAPI.class);

    if (Objects.equals(api.identify(), POWRemoteAPI.IDENTITY)) {
        System.out.println(" --> POW Device detected: " + ip);
        api.setStatusLED(1.0);
        
        return api;
    }
    
    throw new RuntimeException("Cannot connect to " + ip + ":" + port);
}
 
Example 11
Project: jenkins-koji-plugin   File: KojiClient.java   View source code 6 votes vote down vote up
/**
 * Connect to remote Koji instance. Uses custom Transport factory adding a None / null support for XML-RPC.
 *
 * @param kojiInstanceURL Address of the remote Koji server.
 * @return XMLRPC client instance.
 */
private XmlRpcClient connect(String kojiInstanceURL) throws MalformedURLException {
    XmlRpcClient koji = new XmlRpcClient();
    koji.setTransportFactory(new XmlRpcCommonsTransportFactory(koji));
    XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
    koji.setTransportFactory(new XmlRpcCommonsTransportFactory(koji));
    koji.setTypeFactory(new MyTypeFactory(koji));
    config.setEnabledForExtensions(true);
    config.setEnabledForExceptions(true);

    try {
        config.setServerURL(new URL(kojiInstanceURL));
    } catch (MalformedURLException e) {
        throw e;
    }

    koji.setConfig(config);

    return koji;
}
 
Example 12
Project: greenpepper3   File: XmlRpcV3ClientImpl.java   View source code 6 votes vote down vote up
public XmlRpcV3ClientImpl(String url)
		throws XmlRpcClientExecutorException {

	try {
		XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
		config.setServerURL(new URL(url));

		this.client = new XmlRpcClient();

		client.setTransportFactory(new XmlRpcLiteHttpTransportFactory(client));
		client.setConfig(config);
	}
	catch (MalformedURLException ex) {
		throw new XmlRpcClientExecutorException(XML_RPC_URL_NOTFOUND, ex);
	}
}
 
Example 13
Project: fsp   File: XmlRpc.java   View source code 6 votes vote down vote up
@SuppressWarnings("unused")
private void putPage(XmlRpcClient client, String pageName, String content) throws XmlRpcException, SAXParseException
{
	if ((client != null) && (pageName != null) && (content != null))
	{
		// Change logs
		HashMap<String, String> attrs = new HashMap<String, String>();
		attrs.put("sum", "Script FSP " + sdf.format(new Date())); //$NON-NLS-1$ //$NON-NLS-2$

		// Parameters
		Vector<Object> params = new Vector<Object>();
		params.add(pageName);
		params.add(content);
		params.add(attrs);
		client.execute("wiki.putPage", params); //$NON-NLS-1$
	}
}
 
Example 14
Project: hibiscus-watcher   File: Fetcher.java   View source code 6 votes vote down vote up
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;
}
 
Example 15
Project: cloudstack   File: Connection.java   View source code 6 votes vote down vote up
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;
}
 
Example 16
Project: openerp-java-api   File: DemoDbGetter.java   View source code 6 votes vote down vote up
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;
	}
}
 
Example 17
Project: threadfixRack   File: BugzillaDefectTracker.java   View source code 6 votes vote down vote up
@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;
}
 
Example 18
Project: threadfixRack   File: BugzillaDefectTracker.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 19
Project: sync-service   File: ApiCreateFolder.java   View source code 6 votes vote down vote up
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");
	}
 
Example 20
Project: sync-service   File: ApiDeleteMetadataFile.java   View source code 6 votes vote down vote up
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");
	}
 
Example 21
Project: sync-service   File: ApiRestoreMetadata.java   View source code 6 votes vote down vote up
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");
	}
 
Example 22
Project: sync-service   File: ApiPutMetadataFile.java   View source code 6 votes vote down vote up
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");
	}
 
Example 23
Project: sync-service   File: ApiGetMetadata.java   View source code 6 votes vote down vote up
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");
	}
 
Example 24
Project: sync-service   File: ApiPutMetadataFolder.java   View source code 6 votes vote down vote up
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");
	}
 
Example 25
Project: sync-service   File: ApiGetVersions.java   View source code 6 votes vote down vote up
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");
}
 
Example 26
Project: twister.github.io   File: MainRepository.java   View source code 6 votes vote down vote up
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");
    }
}
 
Example 27
Project: twister.github.io   File: ServiceConsole.java   View source code 6 votes vote down vote up
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");
	}
}
 
Example 28
Project: twister.github.io   File: Scheduler.java   View source code 6 votes vote down vote up
public static void main(String [] args){
	try{XmlRpcClientConfigImpl configuration = new XmlRpcClientConfigImpl();
    	configuration.setServerURL(new URL("http://11.126.32.14:88/"));
    	XmlRpcClient client = new XmlRpcClient();
    	client.setConfig(configuration);
    	Scheduler sch = new Scheduler();
    	sch.setRPC(client);
    	sch.init(null, null, null, null,null);
		JFrame f = new JFrame();
		f.add(sch.getContent());
		f.setVisible(true);
		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		f.setBounds(100,100,900,700);
    	System.out.println("Client initialized: "+client);
	}
	catch(Exception e){System.out.println("Could not conect to "+
					"http://11.126.32.14:88 for RPC client initialization");
					e.printStackTrace();
	}
}
 
Example 29
Project: twister.github.io   File: PacketSnifferPlugin.java   View source code 6 votes vote down vote up
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) {
		if(variables!=null && 
		   variables.get("host")!=null &&
		   variables.get("centralengineport")!=null){
			System.out.println("Could not conect to " + variables.get("host")
					+ variables.get("centralengineport"));
		} else {
			System.out.println("Could not connect and initialize RPC connection to server."+
							   "Configuration variables might not be properly set.");
		}
		
	}
}
 
Example 30
Project: twister.github.io   File: JiraPlugin.java   View source code 6 votes vote down vote up
public void initializeRPC(){
System.out.println(this.variables.get("host"));
System.out.println(this.variables.get("centralengineport"));
try{			
	XmlRpcClientConfigImpl configuration = new XmlRpcClientConfigImpl();
	
	configuration.setServerURL(new URL("http://"+this.variables.get("host")+
			":"+this.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 "+
this.variables.get("host")+" :"+this.variables.get("centralengineport")+
"for RPC client initialization");
	}
}
 
Example 31
Project: twister.github.io   File: Scheduler.java   View source code 6 votes vote down vote up
public static void main(String [] args){
	try{XmlRpcClientConfigImpl configuration = new XmlRpcClientConfigImpl();
    	configuration.setServerURL(new URL("http://11.126.32.14:88/"));
    	XmlRpcClient client = new XmlRpcClient();
    	client.setConfig(configuration);
    	Scheduler sch = new Scheduler();
    	sch.setRPC(client);
    	sch.init(null, null, null, null);
		JFrame f = new JFrame();
		f.add(sch.getContent());
		f.setVisible(true);
		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		f.setBounds(100,100,900,700);
    	System.out.println("Client initialized: "+client);
	}
	catch(Exception e){System.out.println("Could not conect to "+
					"http://11.126.32.14:88 for RPC client initialization");
					e.printStackTrace();
	}
}
 
Example 32
Project: mideaas   File: XmlRpcContact.java   View source code 6 votes vote down vote up
public static String ping(String server) {
	
	try{
		XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
		config.setServerURL(new URL(server));
		XmlRpcClient client = new XmlRpcClient();
		client.setConfig(config);

       	HashMap<String, String> result = null;
           result = (HashMap<String, String>)client.execute("ping", new Object[] {"guest"});
           return (String)result.get("ping");
       }
       catch ( Exception ex ) {
       	return "Connection failed";
       }
}
 
Example 33
Project: mideaas   File: XmlRpcContact.java   View source code 6 votes vote down vote up
public static Object executeTests(String server, Map<String, String> map) {
   	Object result = null;
	
	try{
		XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
		config.setServerURL(new URL(server));
		XmlRpcClient client = new XmlRpcClient();
		client.setConfig(config);
       	
           result = client.execute("executeTestCase", new Object[] {map});
       }
       catch ( Exception ex ) {
       	ex.printStackTrace();
       }
	return result;
}
 
Example 34
Project: satellite-plugin   File: SatelliteConnection.java   View source code 6 votes vote down vote up
/**
 * login
 */
public SatelliteConnection login() {
    if (logger == null) {
        logger = new PrintStream(System.out);
    }

    XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
    config.setServerURL(configuration.getRpcUrl());
    config.setEnabledForExtensions(true);

    if (configuration.isSSL()) {
        initializeSSLContext();
    }

    client = new XmlRpcClient();
    client.setConfig(config);

    auth = call("auth.login", configuration.getUser(), configuration.getPassword());

    return this;
}
 
Example 35
Project: bf-editor   File: MetaweblogPoster.java   View source code 5 votes vote down vote up
private void initBlogClient() {
    if (this.blogUrl != null) {
        XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
        config.setServerURL(this.blogUrl);
        config.setEncoding("UTF-8");
        config.setBasicEncoding("UTF-8");

        this.blogClient = new XmlRpcClient();

        blogClient.setConfig(config);

    }
}
 
Example 36
Project: scipio-erp   File: XmlRpcTests.java   View source code 5 votes vote down vote up
/**
 * 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"));
}
 
Example 37
Project: remotesikulilibrary   File: Helper.java   View source code 5 votes vote down vote up
public static void initializeConnection(String URI) {
	SikuliLogger.log("Initializing connection to: "+URI);
	XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
    try {
		config.setServerURL(new URL(URI));
	} catch (MalformedURLException e) {
		SikuliLogger.logDebug(e.getStackTrace());
		throw new RuntimeException(e.getMessage());
	}
    remoteClient = new XmlRpcClient();
    remoteClient.setConfig(config);
    getRemoteKeywords();
    library = new Client();
    remote = true;
}
 
Example 38
Project: remotesikulilibrary   File: HelperTest.java   View source code 5 votes vote down vote up
@Test
public void initializeConnectionCorrectly() {
	XmlRpcClient mockClient = mock(XmlRpcClient.class);
	try {
		whenNew(XmlRpcClient.class).withNoArguments().thenReturn(mockClient);
		doReturn(true).when(mockClient).execute(Mockito.anyString(), Mockito.any(Object[].class));
		Helper.initializeConnection("http://localhost");
	} catch (Exception e1) {
		// TODO Auto-generated catch block
		e1.printStackTrace();
	}
}
 
Example 39
Project: EjabberdXMLRPCClient   File: EjabberdXMLRPCClientBuilder.java   View source code 5 votes vote down vote up
@Override
public IEjabberdXMLRPCClient build() throws MalformedURLException {
    final URL ejabberdUrl = buildUrl();

    XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
    config.setServerURL(ejabberdUrl);

    XmlRpcClient client = new XmlRpcClient();
    client.setConfig(config);

    return new EjabberdXMLRPCClient(this.executorService, client);
}
 
Example 40
Project: EjabberdXMLRPCClient   File: ResponseParserTest.java   View source code 5 votes vote down vote up
private HashMap getResponseObject(InputStream file) throws XmlRpcException, IOException, SAXException {
    final XMLReader xr = SAXParsers.newXMLReader();
    XmlRpcResponseParser xp = new XmlRpcResponseParser(new XmlRpcHttpRequestConfigImpl(), new TypeFactoryImpl(new XmlRpcClient()));
    xr.setContentHandler(xp);
    xr.parse(new InputSource(file));
    return (HashMap) xp.getResult();
}