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)?
No, I don’t believe this is necessary. It is up to the JAX-WS subsystem to manage its own lifecycle, the ports need not be closed.
This is consist with the behaviour of
JaxWsPortProxyFactoryBean, if you look at the source code. It does not attempt to do anything with the Port on context shutdown, which Spring FactoryBeans will generally do.