How to programmatically set JAX-WS 2.1 JMS client timeout in WebSphere 7?
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).getReq开发者_C百科uestContext().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?
See article at http://www.websphere-world.com/modules.php?name=News&file=article&sid=2058. Author, here details steps to set timeout for JAX-WS client in WebSphere. Regards, Mike
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?
精彩评论