In the ServiceClient.configureServiceClient method it assumes that the
ConfigurationContext will not have the AxisService that is target service for
the current invocation as shown in the following code snippet:
---
private void configureServiceClient(ConfigurationContext configContext,
AxisService axisService)
throws AxisFault {
initializeTransports(configContext);
// save the axisConfig and service
this.axisConfig = this.configContext.getAxisConfiguration();
if (axisService != null) {
this.axisService = axisService;
} else {
this.axisService = createAnonymousService();
}
if (this.axisConfig.getService(this.axisService.getName()) == null) {
this.axisService.setClientSide(true);
this.axisConfig.addService(this.axisService);
} else {
throw new AxisFault(Messages.getMessage(
"twoservicecannothavesamename",
this.axisService.getName()));
}
----
What is the rationale for this code i.e. throwing an exception if the service
is already there in the configuration?
If I am invoking multiple operations of the same service (or the same operation
repeatedly multiple times), why cannot I re-use a ConfigurationContext that I
have created previously?
I want to avoid the performance penalty of creating a new configuration context
for the client (i.e. reading the axis2.xml, loading the modules and so forth)
every time I invoke a service. So, I was thinking of creating a
ConfigurationContext and storing it in a ThreadLocal, so that multiple
invocations of the same service in the same thread can use the cached
ConfigurationContext.
Thanks for any info on this.
Shantanu Sen