currency convertor webservice doesnot work in web application
I am trying to configure "http://www.webservicex.net/CurrencyConvertor.asmx" web service in my web application. I generated java client classes using wsdl2java provided with Axis2. Standalone java program works fine.
public double convertINRtoUSD(double inr) throws AxisFault, RemoteException{
//double inr = 10000;
// double rate = conversionRate( Currency.INR,Currency.USD);
CurrencyConvertorCurrencyConvertorSoapStub stub=
new CurrencyConvertorCurrencyConvertorSoapStub();
ConversionRate cr = new ConversionRate();
cr.setToCurrency(Currency.INR);
cr.setFromCurrency(Currency.USD);
ConversionRateResponse response =stub.conversionRate(cr);
double d= inr/response.getConversionRateResult();
System.out.printf( "USD for %f INR = %f\n", inr, d);
return d;
}
but when i use same piece of code in web application. it throws Axisfault exception. please suggest. here is the exception:
SEVERE: Servlet.service() for servlet default threw exception
java.lang.ClassNotFoundException: org.apache.axis2.AxisFault
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getDeclaredMethod(Unknown Source)
at org.springframework.core.LocalVariableTableParameterNameDiscoverer$LocalVariableTableVisitor.resolveMember(LocalVariableTableParameterNameDiscoverer.java:236)
at org.springframework.core.LocalVariableTableParameterNameDiscoverer$LocalVariableTableVisitor.visitEnd(L开发者_JAVA百科ocalVariableTableParameterNameDiscoverer.java:219)
at org.springframework.asm.ClassReader.accept(Unknown Source)
You are missing some JAR files. If I'm not mistaken its the axis2-kernel
jar.
You have to add it to your project.
You can get the JAR from the Axis2 distribution or from Maven if you have that kind of build process.
精彩评论