简体   繁体   中英

Communicate between services in axis2?

We have a web service implementation which maintains a bit of internal state. Now we want to add a separate web service interface which accesses the same internal state of the first web service. Essentially, it'd be two interfaces into the same underlying program. We can package the two web services within the same AAR file, as two services in the same service group.

In this setup, would the two services share a classloader (in which case they could share instantiated classes)? Or is there some other axis2 mechanism for the two implementations to communicate with each other?

It turns out that this "just works". If two services are part of the same service group, then they will use the same classloader. That means they'll have access to the same set of static variables and singletons.

Axis2 also allows you to add parameters to certain configuration objects. Each parameter consists of a name-value pair, where the value can be any object. The environment-wide AxisConfiguration can be used to store parameters which are visible to any other service running within the environment. Within your ServiceLifecycle.startUp() function, call getAxisConfiguration() on the ConfigurationContext argument to retrieve the AxisConfiguration. Then use addParameter() and getParameter() to access parameters.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM