How to Configure A Proxy In Apache Axis2/Java

Archived Content
This article is provided for historical perspective only, and may not reflect current conditions. Please refer to relevant product page for more up-to-date product information and resources.
  • By Saminda Abeyruwan
  • 11 Mar, 2008

Applies To

Project Apache Axis2 / Java 1.3 upward
Environment Any
JDK 1.4 upward


Configuration by Editing the axis2.xml File

In the axis2.xml configuration file, you need to provide a top-level parameter named "Proxy".  The following displays a complete configuration of the proxy configuration:

<parameter name="Proxy">

If an open proxy is used, you can drop the <ProxyUser/> and <ProxyPassword/> elements from the above configuration.


Programmatic Configuration

You have to add the following bit of code to your client or the stub:

HttpTransportProperties.ProxyProperties pp = 
new HttpTransportProperties.ProxyProperties();

The "options" object reference will be avaiable from the stub or the ServiceClient class.


Configuration Through Java Networking Properties

If you would prefer to connect to a proxy without even bothering to edit the axis2 configuration or writing additional code, you should then set Java networking properties. The most commonly used properties are "http.proxyHost", "http.proxyPort" and "http.nonProxyHosts". 

e.g. -Dhttp.proxyPort=5678 -Dhttp.nonProxyHosts=localhost||






Saminda Abeyruwan, Software Engineer, WSO2 Inc. (