Setting socket read timeout with javax.xml.soap.SOAPConnection
You have to create your own URLStreamHandler so that you can set URLConnection parameters like connection timeout and read timeout.
SOAPConnection connection = SOAPConnectionFactory.newInstance().createConnection();
URL endpoint =
new URL(new URL("http://yourserver.yourdomain.com/"),
"/path/to/webservice",
new URLStreamHandler() {
@Override
protected URLConnection openConnection(URL url) throws IOException {
URL target = new URL(url.toString());
URLConnection connection = target.openConnection();
// Connection settings
connection.setConnectTimeout(10000); // 10 sec
connection.setReadTimeout(60000); // 1 min
return(connection);
}
});
SOAPMessage result = connection.call(soapMessage, endpoint);
I have removed some try/catch for clarity.
How to view/change socket connection timeout on Linux?
I think you want /proc/sys/net/ipv4/tcp_syn_retries
. The default is usually 5 or 6 which comes out to around 3 minutes.
Note that these are system-wide.
How do I set the timeout for a JAX-WS webservice client?
I know this is old and answered elsewhere but hopefully this closes this down. I'm not sure why you would want to download the WSDL dynamically but the system properties:
sun.net.client.defaultConnectTimeout (default: -1 (forever))
sun.net.client.defaultReadTimeout (default: -1 (forever))
should apply to all reads and connects using HttpURLConnection which JAX-WS uses. This should solve your problem if you are getting the WSDL from a remote location - but a file on your local disk is probably better!
Next, if you want to set timeouts for specific services, once you've created your proxy you need to cast it to a BindingProvider (which you know already), get the request context and set your properties. The online JAX-WS documentation is wrong, these are the correct property names (well, they work for me).
MyInterface myInterface = new MyInterfaceService().getMyInterfaceSOAP();
Map<String, Object> requestContext = ((BindingProvider)myInterface).getRequestContext();
requestContext.put(BindingProviderProperties.REQUEST_TIMEOUT, 3000); // Timeout in millis
requestContext.put(BindingProviderProperties.CONNECT_TIMEOUT, 1000); // Timeout in millis
myInterface.callMyRemoteMethodWith(myParameter);
Of course, this is a horrible way to do things, I would create a nice factory for producing these binding providers that can be injected with the timeouts you want.
Related Topics
What Does Grep -Po '...\K...' Do? How Else Can That Effect Be Achieved
How to Set Runpath of a Binary
How to Monitor Newly Created File in a Directory with Bash
Case in Bash: "Line 4: Syntax Error Near Unexpected Token ')'"
How to Disable Specific Warning When -Wall Is Enabled
Mod_Rewrite with Relative Path Redirects
How to Configure a Specific Ip in Prometheus Yml Configuration File
How to Initialize the Attribute Group Correctly for a Platform Driver
Zipping Without Creating Parent Folder
How to Run a Linux Command That Still Runs After I Close My Putty Ssh Session
Perl Fork() Exec() , Child Process Gone Wild
Permission Issues, Not Able to Run Script as Root
Some Details on Arm Linux Boot
Docker Container Accessible Only via Cloudflare Cdn (Selected Ip Ranges)