JAX-WS Client Not Honoring CONNECT_TIMEOUT

(Doc ID 1492541.1)

Last updated on NOVEMBER 05, 2016

Applies to:

Oracle Weblogic Server - Version 10.3.2 to 12.1.1.0
Information 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://unknownhost:7001/SampleWebService/HelloWorldWSService?WSDL"),
new QName("http://test.oracle.com/","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

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms