...
A wsdl_first_https sample can be found in the CXF distribution with more detail. Also see this blog entry for another example.
Here is a sample of what your conduit definition might look like:
...
If your service endpoint uses an SSL WSDL location (i.e., "https://xxx?wsdl"), you can configure the http conduit to pick up the SSL configuration by using a hardcoded http conduit name of "{http://cxf.apache.org/}TransportURIResolver.http-conduit". The specific HTTP conduit name or a reg-ex expression can still be used.
...
Attribute | Description |
---|---|
| Specifies the amount of time, in milliseconds, that the client will attempt to establish a connection before it times out. The default is 30000 (30 seconds). |
| Specifies the amount of time, in milliseconds, that the client will wait for a response before it times out. The default is 60000. |
| Specifies if the client will automatically follow a server issued redirection. The default is false. |
| Specifies the maximum number of times a client will retransmit a request to satisfy a redirect. The default is -1 which specifies that unlimited retransmissions are allowed. |
| Specifies whether the client will send requests using chunking. The default is true which specifies that the client will use chunking when sending requests.
|
| Specifies the threshold at which CXF will switch from non-chunking to chunking. By default, messages less than 4K are buffered and sent non-chunked. Once this threshold is reached, the message is chunked. |
| Specifies what media types the client is prepared to handle. The value is used as the value of the HTTP |
| Specifies what language (for example, American English) the client prefers for the purposes of receiving a response. The value is used as the value of the HTTP AcceptLanguage property. |
| Specifies what content encodings the client is prepared to handle. Content encoding labels are regulated by the Internet Assigned Numbers Authority (IANA). The value is used as the value of the HTTP |
| Specifies the media type of the data being sent in the body of a message. Media types are specified using multipurpose internet mail extensions (MIME) types. The value is used as the value of the HTTP |
| Specifies the Internet host and port number of the resource on which the request is being invoked. The value is used as the value of the HTTP |
| Specifies whether a particular connection is to be kept open or closed after each request/response dialog. There are two valid values:
|
| Specifies directives about the behavior that must be adhered to by caches involved in the chain comprising a request from a client to a server. |
| Specifies a static cookie to be sent with all requests. |
| Specifies information about the browser from which the request originates. In the HTTP specification from the World Wide Web consortium (W3C) this is also known as the user-agent. Some servers optimize based upon the client that is sending the request. |
| Specifies the URL of the resource that directed the consumer to make requests on a particular service. The value is used as the value of the HTTP Referer property. |
| Specifies the URL of a decoupled endpoint for the receipt of responses over a separate server->client connection. |
| Specifies the URL of the proxy server through which requests are routed. |
| Specifies the port number of the proxy server through which requests are routed. |
NonProxyHosts | Specifies a list of hosts that should be directly routed. This value is a list of patterns separated by '|', where each pattern may start or end with a '*' for wildcard matching. |
| Specifies the type of proxy server used to route requests. Valid values are:
|
...
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 ?
...