
Explain yourself with reStructured Text, embedded code, graphs, charts, and LaTeX–style math.
Join Siafoo Now
or
Learn More
Simple Java XMLRPC example
0
In Brief | A very simple example on setting up and calling XMLRPC methods from Java, using the wx-xmlrpc library |
Language | Java |
# 's
1import org.apache.xmlrpc.client.XmlRpcClient;
2import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
3import java.net.URL;
4
5public class SimpleXmlrpc {
6
7 public SimpleXmlrpc() {
8 }
9
10 public static void main(String[] args) {
11
12 XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
13
14 try{
15
16 config.setServerURL(new URL("http://example.net/xmlrpc"));
17 XmlRpcClient client = new XmlRpcClient();
18 client.setConfig(config);
19 // Assuming some.method has a 'String', 'Int', 'Int' signature and returns Int
20 Object[] params = new Object[]{ new String("Some Text"),
21 new Integer(38),
22 new Integer(0),
23 };
24
25 Integer result = (Integer)client.execute("some.method", params);
26 System.out.println("Results" + result);
27 }
28 catch(Exception e)
29 {
30 System.out.println("Exception: " + e.getMessage());
31 }
32 }
33}
A very simple example on setting up and calling XMLRPC methods from Java, using the wx-xmlrpc library
Add a Comment