We have written a server application wrapper which internally uses the SOAP webservices. This server application runs on TOMCAT and should handle multiple clients.

In the current implementation, we used to create a proxy object (for SOAP service) for each client requesting to our server. The proxy object contains the bindingprovider information attached. This proxy object is created at the first call while requesting for startsession.

We used to save this proxy object along with the sessionID in the HashMap for any further request to the server application. So when next time a request comes, we used to fetch the respective service object from HashMap and this object was used to call the new SOAP API.

Now we are facing memory issue (outofMemory) because we save complete objects for each client. So at some point of time the Java memory gets full, if there are many clients working concurrently.

To avoid the same, we are wondering if we can create just one SOAP proxy object for all the clients and at runtime we just keep on changing the bindingprovider credentials value for the proxy object i.e. USERNAME_PROPERTY/PASSWORD_PROPERTY at runtime.

As this credentials needs to be present with proxy object for making every soap api request. Please suggest if we can go for this kind of approach.