Description
Had to learn to use xmlrpc these days, and the good documentation helped a lot. However, many of the code examples on the website and in the java-docs won't even compile - outdated. They are mostly minor glitches but still annoying. Here are some examples I can remember:
http://ws.apache.org/xmlrpc/apidocs/org/apache/xmlrpc/webserver/WebServer.html
final int portNumber = 8088;
final String propertyFile = "MyHandler.properties";
PropertyHandlerMapping mapping = new PropertyHandlerMapping();
ClassLoader cl = Thread.currentThread().getContextClassLoader();
mapping.load(cl, propertyFile);
WebServer webServer = new WebServer(port);
XmlRpcServerConfigImpl config = new XmlRpcServerConfigImpl();
XmlRpcServer server = server.getXmlRpcServer();
server.setConfig(config);
server.setHandlerMapping(mapping);
server.start();
- "port" should be "portNumber"
- "server.getXmlRpcServer()" should be "webServer..getXmlRpcServer()"
- "server.start()" should be "webServer.start()"
http://ws.apache.org/xmlrpc/apidocs/org/apache/xmlrpc/webserver/ServletWebServer.html
final int portNumber = 8088;
ClassLoader cl = Thread.currentThread().getContextClassLoader();
XmlRpcServlet servlet = new XmlRpcServlet();
ServletWebServer webServer = new ServletWebServer(servlet, port);
webServer.start();
- "port" should be "portNumber"
- "cl" is never used
http://ws.apache.org/xmlrpc/client.html
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setServerUrl("http://127.0.0.1:8080/XmlRpcServlet");
XmlRpcClient client = new XmlRpcClient();
client.setTransportFactory(new XmlRpcCommonsTransportFactory());
client.setConfig(config);
Object[] params = new Object[]
;
Integer result = (Integer) client.execute("Calculator.add", params);
- "config.setServerUrl("http://127.0.0.1:8080/xmlrpc");" should be "config.setServerURL(new URL("http://127.0.0.1:8080/xmlrpc"));"
- "new XmlRpcCommonsTransportFactory()" should be "new XmlRpcCommonsTransportFactory(client)"
There are probably more lurking around. For the ones I knew how to fix I attached a patch (). What I couldn't fix was:
http://ws.apache.org/xmlrpc/server.html -> Basic Authentication - since PropertyHandlerMapping.newXmlRpcHandlerMapping no longer exists.
PS: I grant license to ASF for inclusion in ASF works (as per the Apache Software License ยง5) ... the create issue form is broken and won't ask about this.