I've code similar to
public static void doIt() {
String myWsdlUrl = "http://www.mycompany.com/WebService";
URL addr = new URL(myWsdlUrl);
QName name = new QName("http://ws.mycompany.com.br/MyService/", "MyService");
MyService ws = new MyService(addr, name);
ws.doSomething("user", "data");
}
After calling ws.doSomething, do I need to close the web service?
I ask this because I can see that every call left a thread running in my Tomcat server...
Also, I'm getting in trouble, after few calls, because the .Net web server (that hosts the server side webservice) start to throws HTTP error 500 (to many threads, it is necessary to clear the thread pool in order to continue).
Perhaps, I was considering a "try with resources" like
public static void doIt() {
String myWsdlUrl = "http://www.mycompany.com/WebService";
URL addr = new URL(myWsdlUrl);
QName name = new QName("http://ws.mycompany.com.br/MyService/", "MyService");
MyService ws = null;
try {
ws = new MyService(addr, name);
ws.doSomething("user", "data");
} finally {
((Port)ws).close(); // don't know if this exists!!!
}
}
I've searched a lot about closing web service client everywhere, and every single example I've seen doesn't have this kind of "close" after usage.
Thanks in advance for any tips.