THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Code Block | ||||
---|---|---|---|---|
| ||||
import org.apache.cxf.endpoint.Client; import org.apache.cxf.frontend.ClientProxy; import org.apache.cxf.transport.http.HTTPConduit; import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; ... URL wsdl = getClass().getResource("wsdl/greeting.wsdl"); SOAPService service = new SOAPService(wsdl, serviceName); Greeter greeter = service.getPort(portName, Greeter.class); // Okay, are you sick of configuration files ? // This will show you how to configure the http conduit dynamically Client client = ClientProxy.getClient(greeter); HTTPConduit http = (HTTPConduit) client.getConduit(); HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); httpClientPolicy.setConnectionTimeout(36000); httpClientPolicy.setAllowChunking(false); httpClientPolicy.setReceiveTimeout(32000); http.setClient(httpClientPolicy); ... greeter.sayHi("Hello"); |
How to use HTTPConduitConfigurer?
In certain cases, the HTTPConduit could be recreated (for example when using the FailoverFeature) and therefore losing the preconfigured policies. To overcome that, the HTTPConduitConfigurer has been introduced. Here is an example of how it could be used.
Code Block | ||||
---|---|---|---|---|
| ||||
HTTPConduitConfigurer httpConduitConfigurer = new HTTPConduitConfigurer() {
public void configure(String name, String address, HTTPConduit c) {
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setConnectionTimeout(36000);
httpClientPolicy.setAllowChunking(false);
httpClientPolicy.setReceiveTimeout(32000);
c.setClient(httpClientPolicy);
}
}
bus.setExtension(httpConduitConfigurer, HTTPConduitConfigurer.class);
|
How to override the service address ?
...