ws-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Olivier Sarrat" <olivier_sar...@hotmail.com>
Subject Re: Connections through a HTTP proxy
Date Thu, 01 Jan 1970 00:00:00 GMT

>Hi all,
>
>I'm trying to connect from RPC client to RPC server through a HTTP proxy
>for 2 reasons:
>1. I like to test it because it has to work through a proxy in live 
>environment
>2. I like to trace the XML messages send/received!
>
>On the client I have
>
>         Properties properties = System.getProperties();
>         properties.setProperty("proxyHost", "http://localhost");
>         properties.setProperty("proxyPort", "8080");
>         properties.setProperty("proxySet", "true");
>         ...
>         rpcClient = new XmlRpcClient("http://localhost:9999");
>
>and I have a server running on port 9999 as well as a http proxy on 8080.
>But the client still does a direct connection to the server - not through
>the HTTP proxy, I can verify that from the proxy logs!  I tried to use
>"http.proxyHost" + "http.proxyPort" as well, but it didn't worked!
>
>Any ideas how to get it work?
>
>Martin Skopp

Hi !

I faced exactly the same problem..

The problem is that you have to deal not only with system properties in 
order to go through a firewall. You have to add the login/password to the 
connection object itself... which means you have to go inside the 
implementation of the client.

The way I did it, is by adding so very few lines at the good place of the 
XmlRpcClient.Worker :

System.setProperty("http.proxySet","true");
System.setProperty("http.proxyHost",proxyHost);
System.setProperty("http.proxyPort",proxyPort);
con.setRequestProperty ("Proxy-Authorization",proxyAuthorization);

with proxyAuthorization being :
proxyAuthorization = "Basic " + new sun.misc.BASE64Encoder
().encode((user + ":" + password).getBytes());

and con, the UrlConnection object.

Another hint: I didn't use the "http://" part I specified my proxyHost... 
but I don't have any idea if it matters or not.

Finally, if you want, I can send you the source of my XmlRpcClientPlus class 
which I derived from the Apache sources of XmlRpcClient. Just ask it 
directly (no need to pollute the list with that...)

That's it !

Olivier Sarrat.

_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com


Mime
View raw message