1

I'm developing Jax-ws client on Jboss 5.1.0 GA. I want to set web service client timeout.

I've tried StubExt.PROPERTY_CLIENT_TIMEOUT.

int timeoutMillisecond=3000;
bp.getRequestContext().put(StubExt.PROPERTY_CLIENT_TIMEOUT, timeoutMillisecond);

It works but exception is thrown only after 3*timeoutMillisecond (after 9000 millisecond), but 3000ms is written in log file.

2012-12-24 15:42:40,053 DEBUG Sending request
2012-12-24 15:42:49,057 ERROR WebServiceException returned: 
javax.xml.ws.WebServiceException: org.jboss.ws.core.WSTimeoutException: Timeout after: 3000ms

I've rtied also many other ways

bp.getRequestContext().put("com.sun.xml.ws.connect.timeout", 100);
bp.getRequestContext().put("com.sun.xml.ws.request.timeout", 100);
// from com.sun.xml.ws.developer.JAXWSProperties
bp.getRequestContext().put(JAXWSProperties.CONNECT_TIMEOUT, 100);
bp.getRequestContext().put(JAXWSProperties.REQUEST_TIMEOUT, 100);

But nothing worked on Jboss 5.1


Could you tell me how to set client timeout correctly ?

Aviram Segal
  • 10,962
  • 3
  • 39
  • 52
JiboOne
  • 1,438
  • 4
  • 22
  • 55
  • possible duplicate of [How to Set Timeout for JAX-WS WebService Call](http://stackoverflow.com/questions/13967069/how-to-set-timeout-for-jax-ws-webservice-call) – McDowell Dec 24 '12 at 11:59

3 Answers3

1

I did the following steps and fixed the problem:

  1. Upgraded jbossws-native library, follow this link.
    jbossws-native-3.4.0 is the latest supported version for Jboss 5.1.0GA. You can see JBossWS - Supported Target Containers

  2. Used StubExt.PROPERTY_CLIENT_TIMEOUT

    int timeoutMillisecond=3000;
    bp.getRequestContext().put(StubExt.PROPERTY_CLIENT_TIMEOUT, timeoutMillisecond);
    

By the way, in this version StubExt.PROPERTY_CONNECTION_TIMEOUT also works correctly.

JiboOne
  • 1,438
  • 4
  • 22
  • 55
0

You can use these settings for your service port.

BindingProvider bindingProvider = (BindingProvider) YOUR_SERVICE_PORT;
Map<String, Object> context = bindingProvider.getRequestContext();
context.put(BindingProviderProperties.CONNECT_TIMEOUT, 3*1000);
context.put(BindingProviderProperties.REQUEST_TIMEOUT,3*1000);
NamingException
  • 2,388
  • 1
  • 19
  • 41
  • BindingProviderProperties.REQUEST_TIMEOUT is the variable name for "com.sun.xml.ws.request.timeout" and BindingProviderProperties.CONNECT_TIMEOUT for "com.sun.xml.ws.connect.timeout" which the OP has already tried and it didnt work. – Lord Nick May 19 '20 at 16:04
0

you're complete missing the point check out code:

URL url = new URL("http://tst.com:9990/ws/hello?wsdl");

    //1st argument service URI, refer to wsdl document above
//2nd argument is service name, refer to wsdl document above
    QName qname = new QName("http://tstsoap/", "HelloWorldImplService");

    Service service = Service.create(url, qname);

   HelloWorld hello = service.getPort(HelloWorld.class);

As you can see, you cannot get a port without creating a service first.
So the timeout always occurs at the service creation. So setting a time for the port is pointless....... Somebody needs to post something about service timeouts....not port timeouts.... Unless somebody can prove me wrong....

pet
  • 17
  • 2