In some tutorials (e.g. here, here and here) it is suggested to close the JAX-WS port by casting it to com.sun.xml.ws.Closeable e.g.
MyPortType port = MyService.getMyPort();
... do some operations on WS proxy ...
((com.sun.xml.ws.Closeable) port).close();
This approach will not work for proxies, returned by JaxWsPortProxyFactoryBean, as it advices only target WS interface and javax.xml.ws.BindingProvider.
So my question is: Is it necessary to close the port (taking in mind that it is re-usable in application)? If it is better to close the port (and probably nullify it?), how to organize correctly lifecycle of ports (by implementation the created Spring proxies will always be singletons)?
The JavaDoc for com.sun.xml.ws.Closeable reads:
This signals the implementation of certain specs (like WS-ReliableMessaging and
WS-SecureConversation) to terminate sessions that they create during the life
time of a proxy object. This is not a mandatory operation, so the application
does not have to call this method.
Also Closing WSIT Reliable Messaging Connections note reads:
Calling close() method provides a way for WSIT components, such as Reliable
Messaging and Secure Conversations to do clean-up activities related to client
instance. Sometimes calling close() can be avoided without harmful effects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With