Announcement Announcement Module
Collapse
No announcement yet.
ws outbound has a bad webserviceTemplate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ws outbound has a bad webserviceTemplate

    In the ws outbound gateway ,the AbstractWebServiceOutboundGateway use a WebServiceTemplate to send and receive soapmessages.
    But i find a problem ,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);
    		}
    	}

  • #2
    Please don't repost/post duplicates.

    No it isn't a bug it is by design. WebServicesTemplate is threadsafe (you could use 1 instance through out your whole application) if the connection would remain open/cached it wouldn't be threadsafe anymore.

    Nor are HttpConnection meant to keep open, they will (eventually) time-out.

    Comment


    • #3
      Thanks,Marten.

      Comment

      Working...
      X