Results 1 to 3 of 3

Thread: WebServiceTemplate has a bad way to createConnection

  1. #1
    Join Date
    Mar 2010
    Posts
    5

    Default 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 at 06:39 AM.

  2. #2
    Join Date
    Apr 2010
    Posts
    11

    Default

    This is maybe a bug.

  3. #3
    Join Date
    Oct 2008
    Location
    Poland, Wrocław
    Posts
    424

    Default

    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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •