Thanks Jason, But my requirement is to have a different client timeout per operation, so setting it with A wildcard on conduit won't do it.
Regards Philippe On Saturday, May 4, 2013, Jason Pell wrote: > You should define a http conduit and you can use a wild card in the id of > the conduit to make sure it applies to your service. > > To ensure it applies to every service you can set a name *.http-conduit > > Because the config of the conduit will be applied at init time its ok no > issues with thread safety. > > http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html > On May 3, 2013 5:57 PM, "Philippe Mouawad" > <pmoua...@apache.org<javascript:;>> > wrote: > > > Hello, > > > > I am working on the right way to configure Client Timeout on client side > > and I am kind of confused by what I read: > > > > - > > > > > http://cxf.547215.n5.nabble.com/Setting-Http-conduit-using-spring-configuration-file-td2644363.html > > - https://issues.apache.org/jira/browse/CXF-3011 > > - > > > > > http://stackoverflow.com/questions/3012787/connection-details-timeouts-in-a-java-web-service-client > > - > > > > > http://stackoverflow.com/questions/3130913/setting-jax-ws-client-timeout/6700210#6700210 > > - > > > > > http://stackoverflow.com/questions/2148915/how-do-i-set-the-timeout-for-a-jax-ws-webservice-client/6700216#6700216 > > > > > > So the things that work: > > > > > > 1) Outside of Spring, this one works fine: > > > > CustomerServiceService customerService = new CustomerServiceService(new > > URL("http://localhost:8080/pyxis/services/customerService?wsdl")); > > CustomerService client = customerService.getCustomerServicePort(); > > Client cl = ClientProxy.getClient(client); > > HTTPConduit http = (HTTPConduit) cl.getConduit(); > > HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); > > httpClientPolicy.setConnectionTimeout(5000); > > httpClientPolicy.setReceiveTimeout(1500); > > http.setClient(httpClientPolicy); > > > > client.myMethod() > > > > > > Question => This would be OK outside of Spring right ? > > > > > > 2) But within Spring, I understand it is not Thread Safe to modify the > > conduit as the service would be a singleton ? > > > > Question => Is it the reason for which it is not fine or did I > > misunderstand ? > > > > > > 3) So I coded this Interceptor: > > > > public class OutTimeoutInterceptor extends > > AbstractPhaseInterceptor<Message> { > > private int receiveTimeout; > > public OutTimeoutInterceptor() { > > super(Phase.PREPARE_SEND); > > } > > public OutTimeoutInterceptor(String phase) { > > super(phase); > > } > > > > public OutTimeoutInterceptor(String phase, boolean uniqueId) { > > super(phase, uniqueId); > > > > } > > > > public OutTimeoutInterceptor(String i, String p, boolean uniqueId) { > > super(i, p, uniqueId); > > > > } > > > > public OutTimeoutInterceptor(String i, String p) { > > super(i, p); > > > > } > > > > @Override > > public void handleMessage(Message message) throws Fault { > > if("{ > > http://customerservice.example.com/}CustomerServiceServiceSoapBinding > > > ".equals(message.getExchange().getBindingOperationInfo().getBinding().getName().toString())) > > { > > message.put(Message.RECEIVE_TIMEOUT, > > getReceiveTimeout()); > > } > > } > > > > /** > > * @return the receiveTimeout > > */ > > public int getReceiveTimeout() { > > return receiveTimeout; > > } > > > > /** > > * @param receiveTimeout the receiveTimeout to set > > */ > > public void setReceiveTimeout(int receiveTimeout) { > > this.receiveTimeout = receiveTimeout; > > } > > > > } > > > > > > Configured this: > > > > <beans xmlns="http://www.springframework.org/schema/beans" > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws=" > > http://cxf.apache.org/jaxws" > > xmlns:jee="http://www.springframework.org/schema/jee" > > xmlns:http-conf=" > > http://cxf.apache.org/transports/http/configuration" > > > > xsi:schemaLocation="http://<http://www.springframework.org/schema/beans>> > *Request context* - on the client side, the request context enables you to > > set properties that affect outbound messages. Request context properties > > are applied to a specific port instance and, once set, the properties > > affect every subsequent operation invocation made on the port, until such > > time as a property is explicitly cleared. For example, you might use a > > request context property to set a connection timeout or to initialize > data > > for sending in a header. > > > > Service = new Service(); > > > > Port = Service.getPort(); > > > > > > ((BindingProvider) Port).getRequestContext().put( > > BindingProviderProperties.CONNECT_TIMEOUT, > > 30); > > ((BindingProvider) Port).getRequestContext().put( > > BindingProviderProperties.REQUEST_TIMEOUT, > > 30); > > > > But it does not and I am confused by this Open bug: > > > > https://issues.apache.org/jira/browse/CXF-3011 > > > > > > Question => Is it supposed to work ? Looking into source code I don't > find > > how but I would like some confirmation ? > > > > > > I will be happy to contribute documentation patch to clarify this as it > > seems to me kind of difficult to find the right answer. > > > > > > Many thanks for your help and thanks for CXF ! > > > > Regards > > > > Philippe > > >