You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Jing Tao <ta...@nceas.ucsb.edu> on 2009/06/25 02:58:46 UTC

How to get ConfigurationContext from a xml file which is in a jar file

Hi, everyone:

I am working to write a web service client and have a customized 
client-axis2.xml.

I used the following code to get a ConfigurationContext object:
ConfigurationContext ctx = 
ConfigurationContextFactory.createConfigurationContextFromFileSystem(".", 
"conf/client.axis2.xml");

Now I put the client.axis2.xml in a jar file rather than file system. The 
sturcture of the jar file looks like:
    0 Wed Jun 24 17:42:44 PDT 2009 META-INF/
    106 Wed Jun 24 17:42:42 PDT 2009 META-INF/MANIFEST.MF
      0 Wed Jun 24 17:42:42 PDT 2009 org/
      0 Wed Jun 24 17:42:42 PDT 2009 org/kepler/
      0 Wed Jun 24 17:42:42 PDT 2009 org/kepler/executionWS/
      0 Wed Jun 24 17:42:44 PDT 2009 org/kepler/executionWS/client/
  25777 Wed Jun 24 17:42:44 PDT 2009 client.axis2.xml
   2210 Wed Jun 24 17:42:42 PDT 2009 log4j.properties
  27832 Wed Jun 24 17:42:44 PDT 2009 org/kepler/executionWS/client/KeplerExeWSClient.class

How can the client class KeplerExeWSClient get a 
ConfigurationContext object? Use the method 
ConfigurationContextFactory.createConfigurationContextFromURIs(axis2xml, 
repositoy)?

Thank you very much for the help!

Jing

Jing Tao
National Center for Ecological
Analysis and Synthesis (NCEAS)
735 State St. Suite 204
Santa Barbara, CA 93101

RE: How to get ConfigurationContext from a xml file which is in a jar file

Posted by "Li, Zhenge" <zh...@cgi.com>.
Tao,

If the config file is in your classpath or can be found in the jar which
is in your classpath, you can try below code block. 

ClassLoader classLoader =
Thread.currentThread().getContextClassLoader();

String name = "path-to-your-axis2.xml"
Axis2ConfigUrl = classLoader.getResource(name);
this.configContext =
ConfigurationContextFactory.createConfigurationContextFromURIs(
                            axis2ConfigAsUrl , null);

This article is a good read if you want to find out 

Different Ways of Creating a ConfigurationContext in Axis2
http://wso2.org/node/585/print

-richard 

-----Original Message-----
From: Jing Tao [mailto:tao@nceas.ucsb.edu] 
Sent: June 24, 2009 9:59 PM
To: axis-user@ws.apache.org
Subject: How to get ConfigurationContext from a xml file which is in a
jar file

Hi, everyone:

I am working to write a web service client and have a customized 
client-axis2.xml.

I used the following code to get a ConfigurationContext object:
ConfigurationContext ctx = 
ConfigurationContextFactory.createConfigurationContextFromFileSystem("."
, 
"conf/client.axis2.xml");

Now I put the client.axis2.xml in a jar file rather than file system.
The 
sturcture of the jar file looks like:
    0 Wed Jun 24 17:42:44 PDT 2009 META-INF/
    106 Wed Jun 24 17:42:42 PDT 2009 META-INF/MANIFEST.MF
      0 Wed Jun 24 17:42:42 PDT 2009 org/
      0 Wed Jun 24 17:42:42 PDT 2009 org/kepler/
      0 Wed Jun 24 17:42:42 PDT 2009 org/kepler/executionWS/
      0 Wed Jun 24 17:42:44 PDT 2009 org/kepler/executionWS/client/
  25777 Wed Jun 24 17:42:44 PDT 2009 client.axis2.xml
   2210 Wed Jun 24 17:42:42 PDT 2009 log4j.properties
  27832 Wed Jun 24 17:42:44 PDT 2009
org/kepler/executionWS/client/KeplerExeWSClient.class

How can the client class KeplerExeWSClient get a 
ConfigurationContext object? Use the method 
ConfigurationContextFactory.createConfigurationContextFromURIs(axis2xml,

repositoy)?

Thank you very much for the help!

Jing

Jing Tao
National Center for Ecological
Analysis and Synthesis (NCEAS)
735 State St. Suite 204
Santa Barbara, CA 93101