You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Nicolas De Loof <ni...@capgemini.com> on 2005/08/24 16:55:37 UTC

[SOLVED] Re: [httpclient] (3-rc3) How to set proxy host/port ?

Thanks for reply,

My problem is I'm using commons-httpclient from an Axis-generated web 
service client. I don't create HttpClient myself.
I've found a workaround by using :

static
{
        String proxyHost = System.getProperty("http.proxyHost");
        String proxyPort = System.getProperty("http.proxyPort");
        if (proxyHost != null && proxyPort != null)
        {
            int port = Integer.parseInt(proxyPort);
            HostConfiguration.ANY_HOST_CONFIGURATION.setProxy(host, port);
        }
}

Notice I've reused java 'standard' system properties for proxy 
configuration.

I have to test it in real world but it seems to work. Thanks for help anyway

Nico.

Oleg Kalnichevski a écrit :

>On Wed, Aug 24, 2005 at 04:14:31PM +0200, Nicolas De Loof wrote:
>  
>
>>Hello,
>>
>>I'd like to set HTTP proxy configuration from an Axis client.
>>
>>I'm using a static bloc to setup commons-httpclient preferences (I'm 
>>using PREEMPTIVE_AUTHENTICATION=true)
>><code>
>>static
>>{
>>   DefaultHttpParams
>>           .setHttpParamsFactory(new CustomDefaultHttpParamsFactory());
>>}
>></code>
>>
>>Is they're any comparable property to set the proxy Host/Port to be used ?
>>
>>    
>>
>
>Nico,
>
>How about that?
>
>HttpClient httpagent = new HttpClient();
>httpagent.getHostConfiguration().setProxy("proxy",
>	8080);
>
>Oleg
>
>
>  
>
>>Nico.
>>
>>This message contains information that may be privileged or confidential 
>>and is the property of the Capgemini Group. It is intended only for the 
>>person to whom it is addressed. If you are not the intended recipient,  you 
>>are not authorized to read, print, retain, copy, disseminate,  distribute, 
>>or use this message or any part thereof. If you receive this  message in 
>>error, please notify the sender immediately and delete all  copies of this 
>>message.
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
>>    
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>  
>

This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient,  you are not authorized to read, print, retain, copy, disseminate,  distribute, or use this message or any part thereof. If you receive this  message in error, please notify the sender immediately and delete all  copies of this message.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: RE : [SOLVED] Re: [httpclient] (3-rc3) How to set proxy host/port ?

Posted by Nicolas De Loof <ni...@capgemini.com>.
Thank, It works fine.

using this, I can force preemptive authentication and set proxy 
configuration without ugly 'static' blocs.

    protected HostConfiguration getHostConfiguration(HttpClient client,
            MessageContext context, URL targetURL)
    {
        HostConfiguration hostConfiguration = super.getHostConfiguration(
            client, context, targetURL);

        if (proxyhost != null)
        {
            hostConfiguration.setProxy(proxyhost, proxyport);
        }
        hostConfiguration.getParams().setBooleanParameter(
            HttpClientParams.PREEMPTIVE_AUTHENTICATION, true);
        return hostConfiguration;
    }


Nico.

Olivier Lamy a écrit :

>change the file called client-config.wsdd.
><transport name="http" pivot="java:fully class name"/>
>fully class name can extends org.apache.axis.transport.http.HTTPSender
>or org.apache.axis.handlers.BasicHandler
> 
>look at the file
>http://cvs.apache.org/viewcvs.cgi/ws-axis/java/src/org/apache/axis/trans
>port/http/CommonsHTTPSender.java?rev=1.42
><http://cvs.apache.org/viewcvs.cgi/ws-axis/java/src/org/apache/axis/tran
>
>sport/http/CommonsHTTPSender.java?rev=1.42&view=markup> &view=markup
>And made your own hack to configure what you want with httpclient.
>I have done it in order to configure my own http soap/axis sender (with
>httpclient)
>Olivier
> 
>
>-----Message d'origine-----
>De : Oleg Kalnichevski [mailto:olegk@apache.org] 
>Envoyé : mercredi 24 août 2005 17:01
>À : commons-user@jakarta.apache.org
>Objet : Re: [SOLVED] Re: [httpclient] (3-rc3) How to set proxy host/port
>?
>
>
>
>On Wed, Aug 24, 2005 at 04:55:37PM +0200, Nicolas De Loof wrote: 
>  
>
>>Thanks for reply, 
>>
>>My problem is I'm using commons-httpclient from an Axis-generated web 
>>service client. I don't create HttpClient myself. 
>>I've found a workaround by using : 
>>
>>static 
>>{ 
>>       String proxyHost = System.getProperty("http.proxyHost"); 
>>       String proxyPort = System.getProperty("http.proxyPort"); 
>>       if (proxyHost != null && proxyPort != null) 
>>       { 
>>           int port = Integer.parseInt(proxyPort); 
>>           HostConfiguration.ANY_HOST_CONFIGURATION.setProxy(host,
>>    
>>
>port); 
>  
>
>>       } 
>>} 
>>
>>Notice I've reused java 'standard' system properties for proxy 
>>configuration. 
>>
>>I have to test it in real world but it seems to work. Thanks for help
>>    
>>
>anyway 
>  
>
>
>Nico, 
>
>This will most certainly produce side-effects. Be advised to not use 
>this workaround with the multithreaded HTTP connection manager. I do not
>
>know much about Axis. I am pretty sure, though, Axis should be able to 
>expose the underlying HttpClient instance for customization 
>
>Oleg 
>
>  
>
>>Nico. 
>>
>>Oleg Kalnichevski a ?crit : 
>>
>>    
>>
>>>On Wed, Aug 24, 2005 at 04:14:31PM +0200, Nicolas De Loof wrote: 
>>>
>>>
>>>      
>>>
>>>>Hello, 
>>>>
>>>>I'd like to set HTTP proxy configuration from an Axis client. 
>>>>
>>>>I'm using a static bloc to setup commons-httpclient preferences (I'm
>>>>        
>>>>
>
>  
>
>>>>using PREEMPTIVE_AUTHENTICATION=true) 
>>>><code> 
>>>>static 
>>>>{ 
>>>> DefaultHttpParams 
>>>>         .setHttpParamsFactory(new
>>>>        
>>>>
>CustomDefaultHttpParamsFactory()); 
>  
>
>>>>} 
>>>></code> 
>>>>
>>>>Is they're any comparable property to set the proxy Host/Port to be
>>>>        
>>>>
>used ? 
>  
>
>>>>  
>>>>
>>>>        
>>>>
>>>Nico, 
>>>
>>>How about that? 
>>>
>>>HttpClient httpagent = new HttpClient(); 
>>>httpagent.getHostConfiguration().setProxy("proxy", 
>>>    8080); 
>>>
>>>Oleg 
>>>
>>>
>>>
>>>
>>>      
>>>
>>>>Nico. 
>>>>
>>>>This message contains information that may be privileged or
>>>>        
>>>>
>confidential 
>  
>
>>>>and is the property of the Capgemini Group. It is intended only for
>>>>        
>>>>
>the 
>  
>
>>>>person to whom it is addressed. If you are not the intended
>>>>        
>>>>
>recipient,  
>  
>
>>>>you are not authorized to read, print, retain, copy, disseminate,  
>>>>distribute, or use this message or any part thereof. If you receive
>>>>        
>>>>
>this  
>  
>
>>>>message in error, please notify the sender immediately and delete
>>>>        
>>>>
>all  
>  
>
>>>>copies of this message. 
>>>>
>>>>
>>>>        
>>>>
>>>--------------------------------------------------------------------- 
>>>      
>>>
>>>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org 
>>>>For additional commands, e-mail:
>>>>        
>>>>
>commons-user-help@jakarta.apache.org 
>  
>
>>>>  
>>>>
>>>>        
>>>>
>>>---------------------------------------------------------------------
>>>      
>>>
>
>  
>
>>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org 
>>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>>      
>>>
>
>  
>
>>>
>>>      
>>>
>>This message contains information that may be privileged or
>>    
>>
>confidential 
>  
>
>>and is the property of the Capgemini Group. It is intended only for
>>    
>>
>the 
>  
>
>>person to whom it is addressed. If you are not the intended recipient,
>>    
>>
>you 
>  
>
>>are not authorized to read, print, retain, copy, disseminate,
>>    
>>
>distribute, 
>  
>
>>or use this message or any part thereof. If you receive this  message
>>    
>>
>in 
>  
>
>>error, please notify the sender immediately and delete all  copies of
>>    
>>
>this 
>  
>
>>message. 
>>
>>
>>--------------------------------------------------------------------- 
>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org 
>>For additional commands, e-mail: commons-user-help@jakarta.apache.org 
>>
>>
>>    
>>
>
>--------------------------------------------------------------------- 
>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org 
>For additional commands, e-mail: commons-user-help@jakarta.apache.org 
>
>
>
>This e-mail, any attachments and the information contained therein ("this message") are confidential and intended solely for the use of the addressee(s). If you have received this message in error please send it back to the sender and delete it. Unauthorized publication, use, dissemination or disclosure of this message, either in whole or in part is strictly prohibited.
>********************************************************************** 
>Ce message électronique et tous les fichiers joints ainsi que  les informations contenues dans ce message ( ci après "le message" ), sont confidentiels et destinés exclusivement à l'usage de la  personne à laquelle ils sont adressés. Si vous avez reçu ce message par erreur, merci  de le renvoyer à son émetteur et de le détruire. Toutes diffusion, publication, totale ou partielle ou divulgation sous quelque forme que se soit non expressément autorisées de ce message, sont interdites.
>********************************************************************** 
>
>
>  
>

This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient,  you are not authorized to read, print, retain, copy, disseminate,  distribute, or use this message or any part thereof. If you receive this  message in error, please notify the sender immediately and delete all  copies of this message.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


RE : [SOLVED] Re: [httpclient] (3-rc3) How to set proxy host/port ?

Posted by Olivier Lamy <ol...@accor.com>.
change the file called client-config.wsdd.
<transport name="http" pivot="java:fully class name"/>
fully class name can extends org.apache.axis.transport.http.HTTPSender
or org.apache.axis.handlers.BasicHandler
 
look at the file
http://cvs.apache.org/viewcvs.cgi/ws-axis/java/src/org/apache/axis/trans
port/http/CommonsHTTPSender.java?rev=1.42
<http://cvs.apache.org/viewcvs.cgi/ws-axis/java/src/org/apache/axis/tran
sport/http/CommonsHTTPSender.java?rev=1.42&view=markup> &view=markup
And made your own hack to configure what you want with httpclient.
I have done it in order to configure my own http soap/axis sender (with
httpclient)
Olivier
 

-----Message d'origine-----
De : Oleg Kalnichevski [mailto:olegk@apache.org] 
Envoyé : mercredi 24 août 2005 17:01
À : commons-user@jakarta.apache.org
Objet : Re: [SOLVED] Re: [httpclient] (3-rc3) How to set proxy host/port
?



On Wed, Aug 24, 2005 at 04:55:37PM +0200, Nicolas De Loof wrote: 
> 
> Thanks for reply, 
> 
> My problem is I'm using commons-httpclient from an Axis-generated web 
> service client. I don't create HttpClient myself. 
> I've found a workaround by using : 
> 
> static 
> { 
>        String proxyHost = System.getProperty("http.proxyHost"); 
>        String proxyPort = System.getProperty("http.proxyPort"); 
>        if (proxyHost != null && proxyPort != null) 
>        { 
>            int port = Integer.parseInt(proxyPort); 
>            HostConfiguration.ANY_HOST_CONFIGURATION.setProxy(host,
port); 
>        } 
> } 
> 
> Notice I've reused java 'standard' system properties for proxy 
> configuration. 
> 
> I have to test it in real world but it seems to work. Thanks for help
anyway 
> 

Nico, 

This will most certainly produce side-effects. Be advised to not use 
this workaround with the multithreaded HTTP connection manager. I do not

know much about Axis. I am pretty sure, though, Axis should be able to 
expose the underlying HttpClient instance for customization 

Oleg 

> Nico. 
> 
> Oleg Kalnichevski a ?crit : 
> 
> >On Wed, Aug 24, 2005 at 04:14:31PM +0200, Nicolas De Loof wrote: 
> > 
> > 
> >>Hello, 
> >> 
> >>I'd like to set HTTP proxy configuration from an Axis client. 
> >> 
> >>I'm using a static bloc to setup commons-httpclient preferences (I'm

> >>using PREEMPTIVE_AUTHENTICATION=true) 
> >><code> 
> >>static 
> >>{ 
> >>  DefaultHttpParams 
> >>          .setHttpParamsFactory(new
CustomDefaultHttpParamsFactory()); 
> >>} 
> >></code> 
> >> 
> >>Is they're any comparable property to set the proxy Host/Port to be
used ? 
> >> 
> >>   
> >> 
> > 
> >Nico, 
> > 
> >How about that? 
> > 
> >HttpClient httpagent = new HttpClient(); 
> >httpagent.getHostConfiguration().setProxy("proxy", 
> >     8080); 
> > 
> >Oleg 
> > 
> > 
> > 
> > 
> >>Nico. 
> >> 
> >>This message contains information that may be privileged or
confidential 
> >>and is the property of the Capgemini Group. It is intended only for
the 
> >>person to whom it is addressed. If you are not the intended
recipient,  
> >>you are not authorized to read, print, retain, copy, disseminate,  
> >>distribute, or use this message or any part thereof. If you receive
this  
> >>message in error, please notify the sender immediately and delete
all  
> >>copies of this message. 
> >> 
> >> 
>
>>--------------------------------------------------------------------- 
> >>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org 
> >>For additional commands, e-mail:
commons-user-help@jakarta.apache.org 
> >> 
> >> 
> >>   
> >> 
> > 
> >---------------------------------------------------------------------

> >To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org 
> >For additional commands, e-mail: commons-user-help@jakarta.apache.org

> > 
> > 
> > 
> 
> This message contains information that may be privileged or
confidential 
> and is the property of the Capgemini Group. It is intended only for
the 
> person to whom it is addressed. If you are not the intended recipient,
you 
> are not authorized to read, print, retain, copy, disseminate,
distribute, 
> or use this message or any part thereof. If you receive this  message
in 
> error, please notify the sender immediately and delete all  copies of
this 
> message. 
> 
> 
> --------------------------------------------------------------------- 
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org 
> For additional commands, e-mail: commons-user-help@jakarta.apache.org 
> 
> 

--------------------------------------------------------------------- 
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org 
For additional commands, e-mail: commons-user-help@jakarta.apache.org 



This e-mail, any attachments and the information contained therein ("this message") are confidential and intended solely for the use of the addressee(s). If you have received this message in error please send it back to the sender and delete it. Unauthorized publication, use, dissemination or disclosure of this message, either in whole or in part is strictly prohibited.
********************************************************************** 
Ce message électronique et tous les fichiers joints ainsi que  les informations contenues dans ce message ( ci après "le message" ), sont confidentiels et destinés exclusivement à l'usage de la  personne à laquelle ils sont adressés. Si vous avez reçu ce message par erreur, merci  de le renvoyer à son émetteur et de le détruire. Toutes diffusion, publication, totale ou partielle ou divulgation sous quelque forme que se soit non expressément autorisées de ce message, sont interdites.
********************************************************************** 


Re: [SOLVED] Re: [httpclient] (3-rc3) How to set proxy host/port ?

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, Aug 24, 2005 at 04:55:37PM +0200, Nicolas De Loof wrote:
> 
> Thanks for reply,
> 
> My problem is I'm using commons-httpclient from an Axis-generated web 
> service client. I don't create HttpClient myself.
> I've found a workaround by using :
> 
> static
> {
>        String proxyHost = System.getProperty("http.proxyHost");
>        String proxyPort = System.getProperty("http.proxyPort");
>        if (proxyHost != null && proxyPort != null)
>        {
>            int port = Integer.parseInt(proxyPort);
>            HostConfiguration.ANY_HOST_CONFIGURATION.setProxy(host, port);
>        }
> }
> 
> Notice I've reused java 'standard' system properties for proxy 
> configuration.
> 
> I have to test it in real world but it seems to work. Thanks for help anyway
> 

Nico,

This will most certainly produce side-effects. Be advised to not use
this workaround with the multithreaded HTTP connection manager. I do not
know much about Axis. I am pretty sure, though, Axis should be able to
expose the underlying HttpClient instance for customization

Oleg

> Nico.
> 
> Oleg Kalnichevski a ?crit :
> 
> >On Wed, Aug 24, 2005 at 04:14:31PM +0200, Nicolas De Loof wrote:
> > 
> >
> >>Hello,
> >>
> >>I'd like to set HTTP proxy configuration from an Axis client.
> >>
> >>I'm using a static bloc to setup commons-httpclient preferences (I'm 
> >>using PREEMPTIVE_AUTHENTICATION=true)
> >><code>
> >>static
> >>{
> >>  DefaultHttpParams
> >>          .setHttpParamsFactory(new CustomDefaultHttpParamsFactory());
> >>}
> >></code>
> >>
> >>Is they're any comparable property to set the proxy Host/Port to be used ?
> >>
> >>   
> >>
> >
> >Nico,
> >
> >How about that?
> >
> >HttpClient httpagent = new HttpClient();
> >httpagent.getHostConfiguration().setProxy("proxy",
> >	8080);
> >
> >Oleg
> >
> >
> > 
> >
> >>Nico.
> >>
> >>This message contains information that may be privileged or confidential 
> >>and is the property of the Capgemini Group. It is intended only for the 
> >>person to whom it is addressed. If you are not the intended recipient,  
> >>you are not authorized to read, print, retain, copy, disseminate,  
> >>distribute, or use this message or any part thereof. If you receive this  
> >>message in error, please notify the sender immediately and delete all  
> >>copies of this message.
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >>
> >>
> >>   
> >>
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >
> > 
> >
> 
> This message contains information that may be privileged or confidential 
> and is the property of the Capgemini Group. It is intended only for the 
> person to whom it is addressed. If you are not the intended recipient,  you 
> are not authorized to read, print, retain, copy, disseminate,  distribute, 
> or use this message or any part thereof. If you receive this  message in 
> error, please notify the sender immediately and delete all  copies of this 
> message.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org