Many broken code examples in the documentation
----------------------------------------------
Key: XMLRPC-108
URL: http://issues.apache.org/jira/browse/XMLRPC-108
Project: XML-RPC
Issue Type: Bug
Components: Source, Website
Affects Versions: 3.0rc1
Reporter: Catalin Hritcu
Priority: Minor
Attachments: xmlrpc3-doc.patch
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[]{new Integer(2), new Integer(3)};
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.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira