task 5 started.
This commit is contained in:
@@ -4,6 +4,7 @@ package client;
|
||||
import java.util.Vector;
|
||||
import java.util.Scanner;
|
||||
import java.net.URL;
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
* Client class for XML-RPC communication
|
||||
@@ -33,16 +34,11 @@ public class Client {
|
||||
// URL can be any valid URL. the default port for XML-RPC is 80
|
||||
// but here we use 8080 since 80 may need root privileges
|
||||
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
|
||||
config.setServerURL(URI.create("http://localhost:8080/RPC2").toURL());
|
||||
// config.setServerURL(new URL("http://localhost:8080/RPC2"));
|
||||
config.setServerURL(new URI("http://localhost:8080/RPC2").toURL());
|
||||
XmlRpcClient client = new XmlRpcClient();
|
||||
client.setConfig(config);
|
||||
|
||||
// Logging of XML-RPC messages between server and client
|
||||
XmlRpcCommonsTransportFactory factory = new XmlRpcCommonsTransportFactory(client);
|
||||
// enable logging
|
||||
factory.setEnableLogging(true);
|
||||
client.setTransportFactory(factory);
|
||||
|
||||
while (true) {
|
||||
// create parameters to be sent to server method in a vector
|
||||
// and populate it
|
||||
@@ -56,7 +52,7 @@ public class Client {
|
||||
// make the remote method call
|
||||
// the result of the remot call must be an Object
|
||||
// and be casted to the appropriate type
|
||||
Object result = client.execute("sample.sum", params);
|
||||
Object result = client.execute("sample.add", params);
|
||||
// process the result
|
||||
int sum = ((Integer) result).intValue();
|
||||
System.out.println("The sum is: " + sum);
|
||||
|
||||
@@ -14,11 +14,6 @@ import java.net.URL;
|
||||
import org.apache.xmlrpc.server.PropertyHandlerMapping;
|
||||
import org.apache.xmlrpc.server.XmlRpcServer;
|
||||
|
||||
// logging imports
|
||||
import java.util.logging.ConsoleHandler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class Server {
|
||||
|
||||
private static String TAG = "Server";
|
||||
@@ -26,6 +21,7 @@ public class Server {
|
||||
public static void main(String[] args) {
|
||||
|
||||
try {
|
||||
|
||||
// start XML-RPC server at port 8080
|
||||
WebServer server = new WebServer(8080);
|
||||
XmlRpcServer xmlRpcServer = server.getXmlRpcServer();
|
||||
|
||||
Reference in New Issue
Block a user