Customizing HttpClient 4.x with Axis 1.7

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Customizing HttpClient 4.x with Axis 1.7

Nick Johnson
With earlier versions of Axis that used Commons-Httpclient, much configuration was possible through setting options, but I notice on perusing the source, that many of the options we used to use are not available for use with HttpClient 4.x, I'm sure in part because HC does a lot of things differently.

Is the way to handle client customizations now to:

1. Extend HTTPSenderImpl and implement a getHttpClient which calls super() and then performs client customizations
2. Extend HTTPClient4TransportSender to provide the custom HTTPSenderImpl in createHTTPSender()

Specifically I need to:

* Disable chunked coding (formerly HTTPConstants.CHUNKED)
* Disable retries (formerly via HTTPConstants.HTTP_METHOD_PARAMS)
* Configure a custom SSL context to possibly allow self-signed SSL certificates (using our own TrustVerifier)  (formerly via HTTPConstants.CUSTOM_PROTOCOL_HANDLER)
* Use a custom Authenticator to support both NTLM and Basic
* Possibly configure a proxy server

We used to achieve all of these settings via setting options using HTTPConstants, but it looks like support only exists now for the Authenticator and Proxy server settings, unless things have moved or gotten implemented in a different way.

I'm not averse to extending HttpSenderImpl and HTTPClient4TransportSender, but if there's a bitter / more elegant way, I'd rather use it.

Any advice?

   Nick
Reply | Threaded
Open this post in threaded view
|

Re: Customizing HttpClient 4.x with Axis 1.7

Jeff Greif
Retries and proxy:  HttpClients.custom().setRetryHandler(), setProxy(). You can specify a limit on the number of retries, depending on your implementation of the handler.

Try checking HttpContext for some of the others.

Also, you might be able to disable chunked encoding via headers on the request.

On Mon, May 1, 2017 at 10:14 AM, Nick Johnson <[hidden email]> wrote:
With earlier versions of Axis that used Commons-Httpclient, much configuration was possible through setting options, but I notice on perusing the source, that many of the options we used to use are not available for use with HttpClient 4.x, I'm sure in part because HC does a lot of things differently.

Is the way to handle client customizations now to:

1. Extend HTTPSenderImpl and implement a getHttpClient which calls super() and then performs client customizations
2. Extend HTTPClient4TransportSender to provide the custom HTTPSenderImpl in createHTTPSender()

Specifically I need to:

* Disable chunked coding (formerly HTTPConstants.CHUNKED)
* Disable retries (formerly via HTTPConstants.HTTP_METHOD_PARAMS)
* Configure a custom SSL context to possibly allow self-signed SSL certificates (using our own TrustVerifier)  (formerly via HTTPConstants.CUSTOM_PROTOCOL_HANDLER)
* Use a custom Authenticator to support both NTLM and Basic
* Possibly configure a proxy server

We used to achieve all of these settings via setting options using HTTPConstants, but it looks like support only exists now for the Authenticator and Proxy server settings, unless things have moved or gotten implemented in a different way.

I'm not averse to extending HttpSenderImpl and HTTPClient4TransportSender, but if there's a bitter / more elegant way, I'd rather use it.

Any advice?

   Nick

Reply | Threaded
Open this post in threaded view
|

Re: Customizing HttpClient 4.x with Axis 1.7

Nick Johnson
Right, and to get Axis to use the custom HttpClient, presumably I will need to do steps 1 and 2 below, given that otherwise, HTTPSenderImpl just does a new DefaultHttpClient()? Or is there a more polite way to hook in a customized client?

   Nick

On Mon, May 1, 2017 at 11:32 AM, Jeff Greif <[hidden email]> wrote:
Retries and proxy:  HttpClients.custom().setRetryHandler(), setProxy(). You can specify a limit on the number of retries, depending on your implementation of the handler.

Try checking HttpContext for some of the others.

Also, you might be able to disable chunked encoding via headers on the request.

On Mon, May 1, 2017 at 10:14 AM, Nick Johnson <[hidden email]> wrote:
With earlier versions of Axis that used Commons-Httpclient, much configuration was possible through setting options, but I notice on perusing the source, that many of the options we used to use are not available for use with HttpClient 4.x, I'm sure in part because HC does a lot of things differently.

Is the way to handle client customizations now to:

1. Extend HTTPSenderImpl and implement a getHttpClient which calls super() and then performs client customizations
2. Extend HTTPClient4TransportSender to provide the custom HTTPSenderImpl in createHTTPSender()

Specifically I need to:

* Disable chunked coding (formerly HTTPConstants.CHUNKED)
* Disable retries (formerly via HTTPConstants.HTTP_METHOD_PARAMS)
* Configure a custom SSL context to possibly allow self-signed SSL certificates (using our own TrustVerifier)  (formerly via HTTPConstants.CUSTOM_PROTOCOL_HANDLER)
* Use a custom Authenticator to support both NTLM and Basic
* Possibly configure a proxy server

We used to achieve all of these settings via setting options using HTTPConstants, but it looks like support only exists now for the Authenticator and Proxy server settings, unless things have moved or gotten implemented in a different way.

I'm not averse to extending HttpSenderImpl and HTTPClient4TransportSender, but if there's a bitter / more elegant way, I'd rather use it.

Any advice?

   Nick


Reply | Threaded
Open this post in threaded view
|

Re: Customizing HttpClient 4.x with Axis 1.7

Martin Gainty
In reply to this post by Jeff Greif

Axis Wsdl2Java code generator does need proxyHost and proxyPort e.g.


wsdl2java [options] -uri [url/path] where options=

--http-proxy-host <host> Proxy host address if you are behind a firewall
--http-proxy-port <port> Proxy port address if you are behind a firewall

command-line-args gets written by org.apache.axis2.wsdl.codegen.CodegenConfigLoader to system parameter(s):

 System.setProperty("http.proxyHost", commandLineOption.getOptionValue())
and/or
 System.setProperty("http.proxyPort", commandLineOption.getOptionValue())

hth

Martin

______________________________________________
 _____ _          _____             _          _____     ___ _                        _____               _     _   _          |_   _| |_ ___   |  _  |___ ___ ___| |_ ___   |   __|___|  _| |_ _ _ _ ___ ___ ___   |   __|___ _ _ ___ _| |___| |_|_|___ ___    | | |   | -_|  |     | . | .'|  _|   | -_|  |__   | . |  _|  _| | | | .'|  _| -_|  |   __| . | | |   | . | .'|  _| | . |   |   |_| |_|_|___|  |__|__|  _|__,|___|_|_|___|  |_____|___|_| |_| |_____|__,|_| |___|  |__|  |___|___|_|_|___|__,|_| |_|___|_|_|                        |_|                                                                                                    




From: [hidden email] <[hidden email]> on behalf of Jeff Greif <[hidden email]>
Sent: Monday, May 1, 2017 2:32 PM
To: [hidden email]
Subject: Re: Customizing HttpClient 4.x with Axis 1.7
 
Retries and proxy:  HttpClients.custom().setRetryHandler(), setProxy(). You can specify a limit on the number of retries, depending on your implementation of the handler.

Try checking HttpContext for some of the others.

Also, you might be able to disable chunked encoding via headers on the request.

On Mon, May 1, 2017 at 10:14 AM, Nick Johnson <[hidden email]> wrote:
With earlier versions of Axis that used Commons-Httpclient, much configuration was possible through setting options, but I notice on perusing the source, that many of the options we used to use are not available for use with HttpClient 4.x, I'm sure in part because HC does a lot of things differently.

Is the way to handle client customizations now to:

1. Extend HTTPSenderImpl and implement a getHttpClient which calls super() and then performs client customizations
2. Extend HTTPClient4TransportSender to provide the custom HTTPSenderImpl in createHTTPSender()

Specifically I need to:

* Disable chunked coding (formerly HTTPConstants.CHUNKED)
* Disable retries (formerly via HTTPConstants.HTTP_METHOD_PARAMS)
* Configure a custom SSL context to possibly allow self-signed SSL certificates (using our own TrustVerifier)  (formerly via HTTPConstants.CUSTOM_PROTOCOL_HANDLER)
* Use a custom Authenticator to support both NTLM and Basic
* Possibly configure a proxy server

We used to achieve all of these settings via setting options using HTTPConstants, but it looks like support only exists now for the Authenticator and Proxy server settings, unless things have moved or gotten implemented in a different way.

I'm not averse to extending HttpSenderImpl and HTTPClient4TransportSender, but if there's a bitter / more elegant way, I'd rather use it.

Any advice?

   Nick

Reply | Threaded
Open this post in threaded view
|

Re: Customizing HttpClient 4.x with Axis 1.7

Nick Johnson
Fortunately, proxy settings don't enter the picture at all for us with wsdl2java; we always ship with precompiled stubs and always explicitly set the service endpoint URIs, etc., before making requests, because we never know for certain what kind of environment in which we will be running, and don't know the addresses of the endpoints or the required network configurations.  This makes dealing with the Java stubs easier for us, at the expense of making the http client configuration more tricky.

   Nick


On Mon, May 1, 2017 at 1:09 PM, Martin Gainty <[hidden email]> wrote:

Axis Wsdl2Java code generator does need proxyHost and proxyPort e.g.


wsdl2java [options] -uri [url/path] where options=

--http-proxy-host <host> Proxy host address if you are behind a firewall
--http-proxy-port <port> Proxy port address if you are behind a firewall

command-line-args gets written by org.apache.axis2.wsdl.codegen.CodegenConfigLoader to system parameter(s):

 System.setProperty("http.proxyHost", commandLineOption.getOptionValue())
and/or
 System.setProperty("http.proxyPort", commandLineOption.getOptionValue())

hth

Martin

______________________________________________
 _____ _          _____             _          _____     ___ _                        _____               _     _   _          |_   _| |_ ___   |  _  |___ ___ ___| |_ ___   |   __|___|  _| |_ _ _ _ ___ ___ ___   |   __|___ _ _ ___ _| |___| |_|_|___ ___    | | |   | -_|  |     | . | .'|  _|   | -_|  |__   | . |  _|  _| | | | .'|  _| -_|  |   __| . | | |   | . | .'|  _| | . |   |   |_| |_|_|___|  |__|__|  _|__,|___|_|_|___|  |_____|___|_| |_| |_____|__,|_| |___|  |__|  |___|___|_|_|___|__,|_| |_|___|_|_|                        |_|                                                                                                    




From: [hidden email] <[hidden email]> on behalf of Jeff Greif <[hidden email]>
Sent: Monday, May 1, 2017 2:32 PM
To: [hidden email]
Subject: Re: Customizing HttpClient 4.x with Axis 1.7
 
Retries and proxy:  HttpClients.custom().setRetryHandler(), setProxy(). You can specify a limit on the number of retries, depending on your implementation of the handler.

Try checking HttpContext for some of the others.

Also, you might be able to disable chunked encoding via headers on the request.

On Mon, May 1, 2017 at 10:14 AM, Nick Johnson <[hidden email]> wrote:
With earlier versions of Axis that used Commons-Httpclient, much configuration was possible through setting options, but I notice on perusing the source, that many of the options we used to use are not available for use with HttpClient 4.x, I'm sure in part because HC does a lot of things differently.

Is the way to handle client customizations now to:

1. Extend HTTPSenderImpl and implement a getHttpClient which calls super() and then performs client customizations
2. Extend HTTPClient4TransportSender to provide the custom HTTPSenderImpl in createHTTPSender()

Specifically I need to:

* Disable chunked coding (formerly HTTPConstants.CHUNKED)
* Disable retries (formerly via HTTPConstants.HTTP_METHOD_PARAMS)
* Configure a custom SSL context to possibly allow self-signed SSL certificates (using our own TrustVerifier)  (formerly via HTTPConstants.CUSTOM_PROTOCOL_HANDLER)
* Use a custom Authenticator to support both NTLM and Basic
* Possibly configure a proxy server

We used to achieve all of these settings via setting options using HTTPConstants, but it looks like support only exists now for the Authenticator and Proxy server settings, unless things have moved or gotten implemented in a different way.

I'm not averse to extending HttpSenderImpl and HTTPClient4TransportSender, but if there's a bitter / more elegant way, I'd rather use it.

Any advice?

   Nick