Thursday, December 3, 2009

Configuring an Axis2 client

I am using Axis2 (version 1.4) for performing SOAP requests.
A customer came up with a requirement to set the HTTP client to use a proxy.

I found the property I need to change in axis2 configuration in the axis2 documentation but I couldn't find documentation on where to place these configuration elements, only some obscure references to axis2.xml.

I configured Axis2 logging to get a better clue of what is used, using commons-logging and setting the log4j.properties to output everything (level ALL).
In the log I understood where Axis2 get the configuration from – it reads it from org/apache/axis2/deployment/axis2_default.xml
I found this file inside axis2-kernel-1.2.jar.
I extracted the file and configured a proxy for the "http" transportSender elements. Then I put the modified file in the classpath and this time the HTTP request went through my proxy.

Great, problem solved, but can I change the location of the file?

I started reading the code in http://grepcode.com (very useful, having all the sources online).
You can set the name and location of the configuration file using JVM properties, if you don’t do so then the default is used.
The JVM property "axis2.repo" is used to set the repository, and "axis2.xml" is used to set the configuration file name.
If you set the repository and not the file name then the expected file name is "axis2.xml".
See http://grepcode.com/file/repo1.maven.org/maven2/org.apache.axis2/axis2-kernel/1.4/org/apache/axis2/deployment/FileSystemConfigurator.java#FileSystemConfigurator.%3Cinit%3E%28java.lang.String,java.lang.String%29

Finally, if the JVM properties are not set then the default configuration resource is used org/apache/axis2/deployment/axis2_default.xml, see
http://grepcode.com/file/repo1.maven.org/maven2/org.apache.axis2/axis2-kernel/1.4/org/apache/axis2/deployment/FileSystemConfigurator.java#FileSystemConfigurator.getAxisConfiguration%28%29

Oded

No comments:

Post a Comment