The code is shown below:
import webservicexnet.Currency;
public class CurrencyConversionClient {
public static void main(String[] args) {
double inr = 10000;
double rate = conversionRate( Currency.INR,Currency.USD);
System.out.printf( "USD for %f INR = %f\n", inr, inr * rate);
}
private static double conversionRate(webservicexnet.Currency fromCurrency, webservicexnet.Currency toCurrency) {
webservicexnet.CurrencyConvertor service = new webservicexnet.CurrencyConvertor();
webservicexnet.CurrencyConvertorSoap port = service.getCurrencyConvertorSoap12();
return port.conversionRate(fromCurrency, toCurrency);
}
}
Method conversionRate() takes enumeration for from currency and to currency. We pass INR
for fromcurrency and USD for tocurrency.
Once we obtain conversion rate then we multiply the value in INR with conversion rate to get equivalent USD value.