Announcement Announcement Module
Collapse
No announcement yet.
WebServiceTemplate has a bad way to createConnection Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • WebServiceTemplate has a bad way to createConnection

    When using WebServiceTemplate to send soapmessage to a same uri,every time it creates a new WebServiceConnection .
    So if i send 10000 times soap message to a same uri 'http://localhost:8080/echo/echoService',the method createConnection() is invoked 10000 times.
    But i want it just invokes the method createConnection() one time ,not 10000 times.
    Is this the WebServiceTemplate bug ?

    the WebServiceTemplate code is :
    connection = createConnection(URI.create(uriString));


    Code:
    	public Object sendAndReceive(String uriString, WebServiceMessageCallback requestCallback,
    			WebServiceMessageExtractor responseExtractor) {
    		Assert.notNull(responseExtractor, "'responseExtractor' must not be null");
    		Assert.hasLength(uriString, "'uri' must not be empty");
    		TransportContext previousTransportContext = TransportContextHolder.getTransportContext();
    		WebServiceConnection connection = null;
    		try {
    			connection = createConnection(URI.create(uriString));// <--- this is here
    			TransportContextHolder.setTransportContext(new DefaultTransportContext(connection));
    			MessageContext messageContext = new DefaultMessageContext(getMessageFactory());
    			
    			return doSendAndReceive(messageContext, connection, requestCallback, responseExtractor);
    		} catch (TransportException ex) {
    			throw new WebServiceTransportException("Could not use transport: " + ex.getMessage(), ex);
    		} catch (IOException ex) {
    			throw new WebServiceIOException("I/O error: " + ex.getMessage(), ex);
    		} finally {
    			TransportUtils.closeConnection(connection);
    			TransportContextHolder.setTransportContext(previousTransportContext);
    		}
    	}
    Last edited by honnom; Apr 6th, 2010, 06:39 AM.

  • #2
    This is maybe a bug.

    Comment


    • #3
      Hi

      If you trace down the execution, you'll see what exactly createConnection() does. In case of commons-httpclient it will you this library's infrastructure (e.g. org.apache.commons.httpclient.MultiThreadedHttpCon nectionManager class) which you can find great documentation about at http://hc.apache.org/httpclient-3.x/performance.html).

      Generally connections are reused and configured in Spring XML for commons-httpclient beans.

      regards
      Grzegorz Grzybek

      Comment

      Working...
      X