解決在使用axis2時,每一次請求產生axis2jar臨時文件,導致佔用大量磁盤空間問題。
方法:在axis2生成的客戶端的Stub類中,設置org.apache.axis2.context.ConfigurationContextFactory第1、2兩個參數爲null。
一、使用Spring設置Stub:
Stub:
< bean id ="stub" class ="...Stub" scope ="prototype" >
< constructor-arg ref ="axisConfigContext" />
</ bean>
org.apache.axis2.context.ConfigurationContextFactory設置: < bean id ="axisConfigContext"
class ="org.apache.axis2.context.ConfigurationContextFactory"
factory-method ="createConfigurationContextFromFileSystem" >
< constructor-arg index ="0" >< null /></ constructor-arg>
< constructor-arg index ="1" >< null /></ constructor-arg>
</ bean>
二、代碼方式實現:
1、實例化一個Context配置:
private static ConfigurationContext configurationContext;
static {
try {
configurationContext = ConfigurationContextFactory
.createConfigurationContextFromFileSystem(null, null);
} catch (AxisFault axisFault) {
axisFault.printStackTrace();
}
}
2、配置到Stub中
YourServiceStub sd=new YourServiceStub(configurationContext);