Running axis2 programmatically

I programmatically start the service in Axis 2 (1.5), for example:

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();

With this setting, a service is created only when the first operation request arrives - how can I get the axis to instantly create a service?

Update: I tried using deployService () rather than cfg.addService () and this will start the service immediately. However, another instance of the service is created when the first request arrives, so no good either.

+3
source share
2 answers

A good way to do this is to have the code call the service immediately after the service starts.

+1
source

org.apache.axis2.engine.ServiceLifeCycle. , , services.xml, ,

<service name="MyService" scope="application" class="com.example.MyService">
...
</service>

com.example.MyService - , ServiceLifeCycle. , . ().

+1

Source: https://habr.com/ru/post/1718785/


All Articles