我正在以编程方式在 Axis 2 (1.5) 中启动服务,如下所示:
ConfigurationContext context = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
AxisConfiguration cfg = context.getAxisConfiguration();
Map<String, MessageReceiver> mrMap = new HashMap<String, MessageReceiver>();
mrMap.put("http://www.w3.org/ns/wsdl/in-only", RPCInOnlyMessageReceiver.class.newInstance());
mrMap.put("http://www.w3.org/ns/wsdl/in-out", RPCMessageReceiver.class.newInstance());
AxisService service = AxisService.createService(MonitorWebService.class.getName(), cfg, mrMap, "", "http://samples", MonitorWebService.class.getClassLoader());
service.setScope("application");
cfg.addService(service);
SimpleHTTPServer server = new SimpleHTTPServer(context, 8080);
server.start();
通过此设置,服务仅在第一个操作请求到达时创建 - 我如何强制 axis 立即构建服务?
更新:我试过使用 deployService() 而不是 cfg.addService(),这会立即启动服务。但是,当第一个请求进入时,会创建另一个服务实例,所以这也不好。
最佳答案
一种俗气的方法是让代码在您启动服务后立即调用服务。
关于java - 以编程方式启动 axis2 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1491438/