在两个不同的地方,Apache XML-RPC的文档建议实例化org.apache.xmlrpc.webserver.ConnectionServer
对象:Custom Data Types和Introspection
然而,当我尝试这样做时:
import java.net.InetAddress;
import java.io.IOException;
import org.apache.xmlrpc.server.PropertyHandlerMapping;
import org.apache.xmlrpc.server.XmlRpcServer;
import org.apache.xmlrpc.server.XmlRpcServerConfigImpl;
import org.apache.xmlrpc.webserver.WebServer;
import org.apache.xmlrpc.webserver.ConnectionServer;
import org.apache.xmlrpc.XmlRpcException;
public class XMLRPCServer extends WebServer {
public XMLRPCServer(int port) throws XmlRpcException, IOException {
super(port);
XmlRpcServer xmlRpcServer = getXmlRpcServer();
PropertyHandlerMapping phm = new PropertyHandlerMapping();
phm.addHandler("MyHandler", MyXMLRPCService.class);
xmlRpcServer.setHandlerMapping(phm);
XmlRpcServerConfigImpl serverConfig = (XmlRpcServerConfigImpl) xmlRpcServer.getConfig();
}
protected XmlRpcStreamServer newXmlRpcStreamServer() {
XmlRpcStreamServer server = new ConnectionServer();
return server;
}
}
我收到此错误:
[javac] <path>/communication/xmlrpc/XMLRPCServer.java:8: error: ConnectionServer is not public in org.apache.xmlrpc.webserver; cannot be accessed from outside package
[javac] import org.apache.xmlrpc.webserver.ConnectionServer;
[javac] ^
我做错了什么吗?或者它是doc / library中的错误?
答案 0 :(得分:0)
我找到了解决方法:
protected XmlRpcStreamServer newXmlRpcStreamServer() {
XmlRpcStreamServer server = super.newXmlRpcStreamServer();
return server;
}