Skip to content

Instantly share code, notes, and snippets.

@aarondai
Last active August 29, 2015 14:04
Show Gist options
  • Save aarondai/45c2e62631bf361b638d to your computer and use it in GitHub Desktop.
Save aarondai/45c2e62631bf361b638d to your computer and use it in GitHub Desktop.
Java: XMLRPC
try(BufferedReader br = new BufferedReader(new FileReader("file.txt"))) {
StringBuilder sb = new StringBuilder();
String line = br.readLine();
while (line != null) {
sb.append(line);
sb.append(System.lineSeparator());
line = br.readLine();
}
String everything = sb.toString();
}
import org.apache.xmlrpc.*;
public class JavaServer {
public Integer sum(int x, int y) {
return new Integer(x + y);
}
public static void main(String[] args) {
try {
System.out.println("Attempting to start XML-RPC Server...");
WebServer server = new WebServer(80);
server.addHandler("sample", new JavaServer());
server.start();
System.out.println("Started successfully.");
System.out.println("Accepting requests. (Halt program to stop.)");
} catch (Exception exception) {
System.err.println("JavaServer: " + exception);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment