JAX-WS Client Not Honoring CONNECT_TIMEOUT
(Doc ID 1492541.1)
Last updated on JANUARY 06, 2023
Applies to:
Oracle WebLogic Server - Version 10.3.2 to 12.1.1.0Information in this document applies to any platform.
Symptoms
Based on doc http://docs.oracle.com/cd/E15523_01/web.1111/e13758/jws.htm#i216838, following code is implemented:
package com.oracle.test;
import java.net.URL;
import java.util.Map;
import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.handler.MessageContext;
import com.sun.xml.ws.client.BindingProviderProperties;
public class TestClient {
public static void main(String[] args) {
HelloWorldWSService service;
long start = System.currentTimeMillis();
try {
service = new HelloWorldWSService(new
URL("http://unknown<HOST>:<PORT>/SampleWebService/HelloWorldWSService?WSDL"),
new QName("http://HOSTNAME/","HelloWorldWSService"));
HelloWorldWS port = service.getHelloWorldWSPort();
Map requestContext = ((BindingProvider) port).getRequestContext();
requestContext.put(BindingProviderProperties.CONNECT_TIMEOUT, 3000);
requestContext.put(BindingProviderProperties.REQUEST_TIMEOUT, 3000);
port.hello("sean");
Map responseContext = ((BindingProvider) port).getResponseContext();
Integer responseCode = (Integer)
responseContext.get(MessageContext.HTTP_RESPONSE_CODE);
System.out.println(responseCode);
} catch (Exception e) {
e.printStackTrace();
}
long end = System.currentTimeMillis();
long elapsed = end - start;
System.out.println("Time spent:" + elapsed/1000);
}
}
import java.net.URL;
import java.util.Map;
import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.handler.MessageContext;
import com.sun.xml.ws.client.BindingProviderProperties;
public class TestClient {
public static void main(String[] args) {
HelloWorldWSService service;
long start = System.currentTimeMillis();
try {
service = new HelloWorldWSService(new
URL("http://unknown<HOST>:<PORT>/SampleWebService/HelloWorldWSService?WSDL"),
new QName("http://HOSTNAME/","HelloWorldWSService"));
HelloWorldWS port = service.getHelloWorldWSPort();
Map requestContext = ((BindingProvider) port).getRequestContext();
requestContext.put(BindingProviderProperties.CONNECT_TIMEOUT, 3000);
requestContext.put(BindingProviderProperties.REQUEST_TIMEOUT, 3000);
port.hello("sean");
Map responseContext = ((BindingProvider) port).getResponseContext();
Integer responseCode = (Integer)
responseContext.get(MessageContext.HTTP_RESPONSE_CODE);
System.out.println(responseCode);
} catch (Exception e) {
e.printStackTrace();
}
long end = System.currentTimeMillis();
long elapsed = end - start;
System.out.println("Time spent:" + elapsed/1000);
}
}
However, if the unknown Host is a non-existing server, it timed out after 20 seconds, instead of the configured 3 seconds.
It should timeout with the timeout value specified.
Cause
To view full details, sign in with your My Oracle Support account. |
|
Don't have a My Oracle Support account? Click to get started! |
In this Document
Symptoms |
Cause |
Solution |
References |