@Override protected XmlRpcHandlerMapping newXmlRpcHandlerMapping() throws XmlRpcException { PropertyHandlerMapping phm = new PropertyHandlerMapping(); phm.addHandler("acma", WebService.class); XmlRpcSystemImpl.addSystemHandler(phm); return phm; }
/** * Starts the server * * @throws Exception */ public XMLRPCServer() throws Exception { if (LocalSettings.hasProperty(LocalSettings.SERVER_PORT)) { port = Integer.valueOf(LocalSettings.getProperty(LocalSettings.SERVER_PORT)); } webServer = new WebServer(getPort()); XmlRpcServer xmlRpcServer = webServer.getXmlRpcServer(); ((XmlRpcStreamServer) xmlRpcServer) .setErrorLogger( new XmlRpcErrorLogger() { @Override public void log(java.lang.String pMessage) { Log.Debug(this, pMessage); } @Override public void log(java.lang.String pMessage, java.lang.Throwable pThrowable) { Log.Debug(this, pMessage); Log.Debug(pThrowable); } }); PropertyHandlerMapping phm = new XPropertyHandlerMapping(); // ArrayList<Context> cx = Context.getImportableContexts(); // for (int i = 0; i < cx.size(); i++) { // Context context = cx.get(i); // } phm.addHandler("remote", XMLRPCHandler.class); xmlRpcServer.setHandlerMapping(phm); XmlRpcServerConfigImpl serverConfig = (XmlRpcServerConfigImpl) xmlRpcServer.getConfig(); serverConfig.setEnabledForExtensions(true); serverConfig.setContentLengthOptional(false); PropertyHandlerMapping mapping = (PropertyHandlerMapping) ((XmlRpcStreamServer) xmlRpcServer).getHandlerMapping(); XmlRpcSystemImpl.addSystemHandler(mapping); webServer.start(); Log.Debug(this, "XML RPC Server started! Listening port: " + port); if (Log.getLoglevel() == Log.LOGLEVEL_DEBUG) { Log.Debug(this, "XML RPC Server handler: "); String[] lm = phm.getListMethods(); for (int i = 0; i < lm.length; i++) { String string = lm[i]; Log.Debug(this, string); } } }
protected XmlRpcHandlerMapping newXmlRpcHandlerMapping() throws XmlRpcException { PropertyHandlerMapping mapping = (PropertyHandlerMapping) this; AbstractReflectiveHandlerMapping.AuthenticationHandler handler = new AbstractReflectiveHandlerMapping.AuthenticationHandler() { @Override public boolean isAuthorized(XmlRpcRequest pRequest) { XmlRpcHttpRequestConfig config = (XmlRpcHttpRequestConfig) pRequest.getConfig(); return isAuthenticated(config.getBasicUserName(), config.getBasicPassword()); } }; mapping.setAuthenticationHandler(handler); return mapping; }
public void init() { try { server = new XmlRpcServletServer(); mapping = new PropertyHandlerMapping(); cl = Thread.currentThread().getContextClassLoader(); // Here we load the property handler file mapping.load(cl, (propertyFilePath + propertyFile)); server.setHandlerMapping(mapping); serverConfig = (XmlRpcServerConfigImpl) server.getConfig(); serverConfig.setEnabledForExceptions(true); serverConfig.setEnabledForExtensions(true); server.setConfig(serverConfig); } catch (XmlRpcException e) { e.getMessage(); } catch (IOException e) { e.getMessage(); } }