views:

1055

answers:

1

I'm converting a JAX-RPC client and service to JAX-WS, and am trying to figure out how to set the client timeout programmatically. This will be a JAX-WS 2.1 client running in WebSphere 7. In JAX-RPC, there was a property I could set on the SOAPBindingStub to set the timeout.

In the JAX-WS code, I've tried setting several properties as follows, with no luck:

PolicyFinderService policyFinderService = new PolicyFinderService();
PolicyFinder policyFinder = policyFinderService.getPolicyFinderSOAPPort();
((BindingProvider)policyFinder).getRequestContext().put(com.ibm.wsspi.websvcs.Constants.REQUEST_TIMEOUT_PROPERTY, 1);
((BindingProvider)policyFinder).getRequestContext().put(com.ibm.wsspi.websvcs.Constants.WRITE_TIMEOUT_PROPERTY, 1);
((BindingProvider)policyFinder).getRequestContext().put(com.ibm.wsspi.webservices.Constants.READ_TIMEOUT_PROPERTY, 1);
((BindingProvider)policyFinder).getRequestContext().put(com.ibm.wsspi.webservices.Constants.RESPONSE_TIMEOUT_PROPERTY, 1);
((BindingProvider)policyFinder).getRequestContext().put(com.ibm.wsspi.webservices.Constants.WRITE_TIMEOUT_PROPERTY, 1);

None of these have any effect when I make a call and the service isn't running, it just hangs for the default timeout value (I think 5 minutes) before timing out.

Has anyone found a way to programatically set this timeout value in WebSphere 7?

+1  A: 

its possible you might need to

((BindingProvider)policyFinder).getRequestContext().put(
  com.ibm.wsspi.webservices.Constants.CONNECTION_TIMEOUT_PROPERTY, 2000);

it might do that before the write...possibly

perhaps this also?

reqCtx.put(JAXWSProperties.CONNECT_TIMEOUT, 10); 
reqCtx.put(BindingProviderProperties.REQUEST_TIMEOUT, 10);

possibly REQUEST_TIMEOUT_PROPERTY may actually be in milliseconds, so maybe a low val of 1 gets rounded somehow to 0 (infinite) later on... maybe try 2000?

jspcal
Thanks, I'll give those both a try.
Kaleb Brasee
It was the com.ibm.wsspi.webservices.Constants.CONNECTION_TIMEOUT_PROPERTY! The current configuration is having trouble making the connection, so it never even gets to the other timeouts -- hence the connection timeout is needed. Only thing is, it's in seconds, not milliseconds (I used a value of 10). But still, this is exactly what I was looking for. Thanks!
Kaleb Brasee