Where do I put axis2.xml for reading with a jar of soap client?

I have a java console application inside a jar file. It calls the soap service calls through axis2 . I use this blog as an example. The exact configuration items that I add are as follows:

<parameter name="Proxy"> <Configuration> <ProxyHost>localhost</ProxyHost> <ProxyPort>8888</ProxyPort> </Configuration> </parameter> 

I tried putting this in the axis2.xml file in the root of my jar. I also edited C:\Program Files\Apache Software Foundation\axis2-1.5.4\conf\axis2.xml .

My AXIS2_HOME is installed correctly:

 set AXIS2_HOME AXIS2_HOME=c:\Program Files\Apache Software Foundation\axis2-1.5.4 

I checked that the traffic is definitely sent directly to the server through WireShark .

+4
source share
1 answer

You are having this problem because the JRE cannot find the configuration file.

Yes, the configuration file must be placed outside the jar file because the program cannot read the configuration file inside the jar file (which is compressed).

The problem is that you must correctly specify your program in the configuration file.

Relative file paths are calculated based on where the Java Runtime Environment was launched. (We must use relative file paths because we want to avoid using absolute file paths, since not everyone will have the same system environment, and therefore absolute file paths will not work in another environment)

In this case, if you do not know where your JRE is launched from, you cannot calculate your relative path to the file, you can do:

 File file = new File(""); System.out.println(file.getAbsolutePath()); 

This will help you find out where the JRE starts from. You should be aware that relative file paths are computed from the directory in which your JRE is running.

For axis2, the working directory (where the JRE is running) should be the bin folder of your Apache Tomcat, while for your program it will depend on where you made the JRE call to start the program.

I would advise you to place the configuration file in the place where it is easily accessible. Say if you want to use AXIS2_HOME and you put your configuration file in the AXIS2_HOME directory, you can do the following inside your jar program to find the configuration file:

 String value = System.getenv("AXIS2_HOME"); // gets the AXIS2_HOME environment variable File file = new File(value+"/"+axis2.xml); 

I think that you get the gist of what I am saying. Hope this helps! (

+1
source

All Articles