We have a requirement to pass SOAP Message to the Web service server. Currently we are creating the SOAP messages using SAAJ (SOAP with attachments API for java) APIs provided by SUN. The external system from where we are consuming the webservices has 2 Web servers behind a load balancer to serve the SOAP request. We are using SOAPConnection API of the javax.xml.soap package for connecting to the Web Service. Using this we are able to create SOAPMessage and send to Web Service for execution.
However, the requirement is to create a Connection Pool with the SOAP connections to the Web Service. To do this, we need some clarification
1) Is it worth creating SOAP connection (object) pool with SOAPConnection object? Because, as per the API, the actual connection to the webservice takes only when call() method of the SOAPConnection is invoked.In the same method call the connection and message passing to Web Service service is happening.
2) Is there any techniques in java to pass SOAP Message over HTTP which facilitates connection pooling aswell?
From your post it seems that you use HTTP as your transport mechanism. You can't pool HTTP connections. They're opened, a request is sent, a response is received, then they're closed. The only way to reuse them is via a mechanism called HTTP pipelining, which lets you send several requests in a row over the same connection. But that has nothing to do with SOAP, it's pure HTTP, and not generally applicable to SOAP. Having said that, it might be worthwhile to pool SOAPConnection objects, but I can't imagine that discarding and recreating them introduces a significant overhead over pooling them, because the major time-consuming operation they do is opening the network connection, which -as outlined above- would still have to be done every time.
subject: Connection pooling of SOAPConnection objects