doubt: new to xmlrpc programming
padmaramya p <[email protected]>
| Newsgroups | gmane.text.xml.rpc.specification |
|---|---|
| Message-ID | <[email protected]> |
i am new to java as wellas to xml rpc i have a doubt these are the programs
program:AreaHandler
public class AreaHandler {
public Double rectArea(double length, double width) {
return new Double(length*width);
}
public Double circleArea(double radius) {
double value=(radius*radius*Math.PI);
return new Double (value);
}
}
program: AreaServer
import java.io.IOException;
import org.apache.xmlrpc.WebServer;
import org.apache.xmlrpc.XmlRpc;
public class AreaServer {
public static void main(String[] args)throws IOException {
if (args.length < 1) {
System.out.println(
"Usage: java AreaServer [port]");
System.exit(-1);
}
// Start the server, using built-in version
System.out.println("Attempting to start XML-RPC Server...");
WebServer server = new WebServer(Integer.parseInt(args[0]));
System.out.println("Started successfully.");
// Register our handler class as area
server.addHandler("area", new AreaHandler( ));
System.out.println(
"Registered AreaHandler class to area.");
System.out.println("Now accepting requests. (Halt program to stop.)");
}
}
program:AreaClient
import java.io.IOException;
import java.lang.*;
import java.util.Vector;
import org.apache.xmlrpc.XmlRpc;
import org.apache.xmlrpc.XmlRpcClient;
import org.apache.xmlrpc.XmlRpcException;
public class AreaClient {
public static void main(String args[]) {
if (args.length < 1) {
System.out.println(
"Usage: java AreaClient [radius]");
System.exit(-1);
}
try {
// Create the client, identifying the server
XmlRpcClient client =
new XmlRpcClient("http://mss-b8gg9t34l4l:8899/");
// Create the request parameters using user input
Vector params = new Vector( );
params.addElement(new Double(args[0]));
// Issue a request
Object result =
client.execute("area.circleArea", params);
// Report the results
System.out.println("The area of the circle would be: " + result.toString( ));
} catch (IOException e) {
System.out.println("IO Exception: " + e.getMessage( ));
} catch (XmlRpcException e) {
System.out.println("Exception within XML-RPC: " + e.getMessage( ));
}
}
}
I executed all the three files such as AreaHandler,Server,Client but whlie executing AreaClient i am getting this below mentioned run time error
Exception in thread "main" 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>(XmlRpcClientRe
sponseProcessor.java:48)
at org.apache.xmlrpc.XmlRpcClientWorker.<init>(XmlRpcClientWorker.java:4
3)
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 AreaClient.main(AreaClient.java:27)
its urgent i have a demo tommorrow.i need help.
Ramya.
---------------------------------
Jiyo cricket on Yahoo! India cricket
Yahoo! Messenger Mobile Stay in touch with your buddies all the time.
[Non-text portions of this message have been removed]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/xml-rpc/
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/