public class BAMCepUtils {
Log log = LogFactory.getLog(BAMCepUtils.class);
protected synchronized void invokeSoapClient(OMElement payLoad, EndpointReference reference){
// creates a new connection manager and a http client object
MultiThreadedHttpConnectionManager httpConnectionManager =
new MultiThreadedHttpConnectionManager();
HttpClient httpClient = new HttpClient(httpConnectionManager);
ServiceClient serviceClient=null;
try {
serviceClient = new ServiceClient();
Options options = new Options();
options.setAction("http://ws.apache.org/ws/2007/05/eventing-extended/Publish");
options.setTo(reference);
serviceClient.setOptions(options);
// set the above created objects to re use.
serviceClient.getOptions().setProperty(HTTPConstants.REUSE_HTTP_CLIENT,
Constants.VALUE_TRUE);
serviceClient.getOptions().setProperty(HTTPConstants.CACHED_HTTP_CLIENT,
httpClient);
serviceClient.fireAndForget(payLoad);
} catch (AxisFault axisFault) {
axisFault.printStackTrace();
}
finally {
if (serviceClient!= null) {
try {
serviceClient.cleanupTransport();
} catch (Exception e) {
log.error("Could not clean the transport", e);
}
try {
serviceClient.cleanup();
} catch (Exception e) {
log.error("Could not clean service client", e);
}
}
}
httpConnectionManager.closeIdleConnections(0);
httpConnectionManager.shutdown();
}