Hello i want create gui for aria2c( internet download manager ) with java for doing this aria2c has built in xmlrpc. i use xmlRpc to create gui for aria2c. in aria2c support site there is a example code for python programming language that uses xmlrpc

>>> import xmlrpclib
>>> s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
>>> s.aria2.addUri(['http://example.org/file'])
'1'

i write this java code for doing this in java

package Aria2c;

import java.net.MalformedURLException;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
import java.net.URL;
import org.apache.xmlrpc.client.XmlRpcClient;
import java.util.Vector;

public class JavaClient{
	
	private static Vector< String > params;
	public JavaClient( )
	{
		params.add("http://rs230dt.rapidshare.com/files/344243800/10012723.LinuxCBT.Debian.part8.rar");
	}
    	public static void main( String[] args )
    	{
    		XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
    		try {
				config.setServerURL(new URL("http://localhost:6800/rpc"));
			} catch (MalformedURLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
    		XmlRpcClient client = new XmlRpcClient();
    		client.setConfig(config);
    		   		
    		try {
				client.execute("aria2.addUri", params );
			} catch (XmlRpcException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}

    }
}

but when i want compile this i have these exceptions

org.apache.xmlrpc.XmlRpcException: Failed to read server's response: Connection refused
	at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:161)
	at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:143)
	at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:69)
	at org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:56)
	at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:167)
	at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:158)
	at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:147)
	at Aria2c.JavaClient.main(JavaClient.java:30)
Caused by: java.net.ConnectException: Connection refused
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:310)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:176)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:163)
	at java.net.Socket.connect(Socket.java:546)
	at java.net.Socket.connect(Socket.java:495)
	at sun.net.NetworkClient.doConnect(NetworkClient.java:174)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:409)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:530)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:240)
	at sun.net.www.http.HttpClient.New(HttpClient.java:321)
	at sun.net.www.http.HttpClient.New(HttpClient.java:338)
	at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:814)
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:755)
	at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:680)
	at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:858)
	at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.writeRequest(XmlRpcSunHttpTransport.java:104)
	at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:151)
	... 7 more
Caused by:
java.net.ConnectException: Connection refused
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:310)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:176)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:163)
	at java.net.Socket.connect(Socket.java:546)
	at java.net.Socket.connect(Socket.java:495)
	at sun.net.NetworkClient.doConnect(NetworkClient.java:174)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:409)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:530)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:240)
	at sun.net.www.http.HttpClient.New(HttpClient.java:321)
	at sun.net.www.http.HttpClient.New(HttpClient.java:338)
	at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:814)
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:755)
	at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:680)
	at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:858)
	at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.writeRequest(XmlRpcSunHttpTransport.java:104)
	at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:151)
	at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:143)
	at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:69)
	at org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:56)
	at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:167)
	at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:158)
	at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:147)
	at Aria2c.JavaClient.main(JavaClient.java:30)

how i can improve this cod?
please help me
thanks

Comments
Posted code, and the problem that they were having.

I had problems with XML-RPC in Java a few months back, but eventually got it working. It looks like you're heading in the right direction. You seem to be using the correct libraries.

Do you know why the connection is being refused? Is it possible that you need to authenticate yourself first using a username and password?

I will have a look at this code tonight when I get home, and see if I can figure out what the problem is.

Do you have a link to the documentation for this API?

This article has been dead for over six months. Start a new discussion instead.