以编程方式启动axis2服务 [英] Starting an axis2 service programmatically
问题描述
我正在以编程方式在Axis 2(1.5)中启动服务,
I'm programmatically starting a service in Axis 2 (1.5), like this:
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立即构建服务?
With this set up, the service is only created when the first operation request arrives - how can I force axis to construct the service immediately?
更新:我尝试使用deployService()而不是cfg.addService(),这将立即启动服务.但是,当第一个请求进入时,会创建该服务的另一个实例,所以也没有好处.
Update: I've tried using deployService(), rather than cfg.addService(), and this starts the service up immediately. However, another instance of the service is created when the first request comes in, so that's no good either.
推荐答案
一种俗气的方法是在启动服务后立即让代码调用服务.
A cheesy way to do it would be to have the code call the service immediately after you start the service.
这篇关于以编程方式启动axis2服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!