no no scusa.. e' che ero di fretta e non son riuscito a fare un post un po' completo..
Dunque... io volevo provare a scrivere un client in java che si connette ad un server scritto in php. Ho trovato un sito che aveva un esempio ma facendo copia incolla non va una mazza.
In C:\j2sdk1.4.2_12\jre\lib\ext ho piazzato il file xmlrpc-2.0.jar..
Questo e' l'errore che mi da' Netbeans
Codice PHP:
compile:
run:
java.lang.NoClassDefFoundError: org/apache/commons/codec/DecoderException
at org.apache.xmlrpc.XmlRpc.createTypeFactory(XmlRpc.java:238)
at org.apache.xmlrpc.XmlRpc.<init>(XmlRpc.java:193)
at org.apache.xmlrpc.XmlRpcClientResponseProcessor.<init>(XmlRpcClientResponseProcessor.java:48)
at org.apache.xmlrpc.XmlRpcClientWorker.<init>(XmlRpcClientWorker.java:43)
at org.apache.xmlrpc.XmlRpcClient.getWorker(XmlRpcClient.java:347)
at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:190)
at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:184)
at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:177)
at Main.main(Main.java:37)
Exception in thread "main"
Java Result: 1
BUILD SUCCESSFUL (total time: 2 seconds)
Questo e' il codice del client java...
Codice PHP:
/*
* Listato 2
* Un client per il servizio XML-RPC ‘successore’
*/
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Vector;
import org.apache.xmlrpc.*;
public class Main {
public static void main(String[] args) {
/*
if (args.length != 1) {
System.out.println("Uso: java XmlRpcClient1 <intero>");
System.exit(1);
}
*/
// URL del server XML-RPC
final String url = "http://192.16.1.8/apache2-defauct/server.php";
// Creazione istanza client XML-RPC
XmlRpcClient xmlrpc = null;
try {
xmlrpc = new XmlRpcClient(url);
} catch (MalformedURLException urle) {
System.out.println("URL exception:" + urle.toString());
System.exit(1);
}
// Parametri da passare al metodo XML-RPC
Vector params = new Vector();
Integer param = null;
try {
param = new Integer(2);
} catch (Exception e) {
System.out.println("Exception:" + e.toString()); }
params.addElement(param);
// Esecuzione chiamata XML-RPC
try {
System.out.println( xmlrpc.execute("esempio.mat.successore", params) );
} catch(XmlRpcException rpce) {
System.out.println("Eccezione XML-RPC: " + rpce.toString());
} catch(IOException ioe) {
System.out.println("IO exception: " + ioe.toString());
}
}
}
Non capisco a cosa sia dovuto l'errore......