WSO2Con 2013 CFP Banner

How do I setup my Axis2 generated stub to Reuse/share http connections?

Archived Content
This article is provided for historical perspective only, and may not reflect current conditions. Please refer to relevant product page for more up-to-date product information and resources.
Discuss this article on Stack Overflow
By Davanum Srinivas
  • 10 May, 2006
  • Level: 
  • Reads: 8480

Q: How do I setup my Axis2 generated stub to reuse/share http connections across several calls?

Davanum Srinivas

WSO2 Inc.

A: It's not too complicated..

TestServiceStub myStub = new TestServiceStub(wsURL);
http.HTTPConstants.REUSE_HTTP_CLIENT, new Boolean(true));
In fact if you need more control over the Commons HTTPClient's MultiThreadedHttpConnectionManager, you can even set it up yourself and then use the above snippet to make sure it gets used.
ConfigurationContext context = ConfigurationContextFactory.
createConfigurationContextFromFileSystem(null, null);
HttpClient httpClient = new HttpClient(new MultiThreadedHttpConnectionManager());
context.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
For any further details or questions (Prefix subject with with [Axis2])