Our application should send some request to the SOAP service. We use the wsimport command to generate a class for our client. But sometime during maintenance or some kind of network problem, our request freezes up to timeout, and it takes too long. We want to control the timeout value so that we use the server-side method.
To call the service method after reading from another message, we set up something like this:
((BindingProvider) port).getRequestContext().put("sun.net.client.defaultReadTimeout", 3000);
((BindingProvider) port).getRequestContext().put("sun.net.client.defaultConnectTimeout", 10000);
But before that, we need to call get port, which will read the wsdl file. We are trying to create a url like this:
url = new URL(null, "http://theirsite/WS?WSDL", new URLStreamHandler() {
@Override
protected URLConnection openConnection(URL url) throws IOException {
logger.info("URLStreamHandler got call!");
URL clone_url = new URL(url.toString());
HttpURLConnection clone_connection
= (HttpURLConnection) clone_url.openConnection();
clone_connection.setConnectTimeout(5000);
clone_connection.setReadTimeout(3000);
return (clone_connection);
}
});
And then we use this url as a parameter when creating the Service object. But our URLStreamHandler never received a call.
:
System.setProperty("sun.net.client.defaultReadTimeout", "" + 3000);
System.setProperty("sun.net.client.defaultConnectTimeout", "" + 5000);
.
any1 ? ? , wsdl .