我正在尝试在 android 中使用webservicex.net使用 ksoap2 进行货币转换。
但是,它返回 0!!它甚至不会抛出任何异常,即使我提供错误的参数也只会返回 0,尽管使用提供的 web 服务它工作得很好。
String NAME_SPACE = "http://www.webservicex.net/";
Static String URL = "http://www.webservicex.net/currencyconvertor.asmx";
Static String SOAP_ACTION = "http://www.webserviceX.NET/ConversionRate";
Static String METHOD_NAME = "ConversionRate";
String webResult = null;
SoapObject request = new SoapObject(Strings.NAME_SPACE, Strings.METHOD_NAME);
request.addProperty("FromCurrency", "USD");
request.addProperty("ToCurrency", "PKR");
SoapSerializationEnvelope envelop = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelop.dotNet = true;
envelop.setOutputSoapObject(request);
HttpTransportSE androidHttpRequest = new HttpTransportSE(Strings.URL);
androidHttpRequest.debug = true;
try {
for (int i = 0; i < 3; i++) {
androidHttpRequest.call(Strings.SOAP_ACTION, envelop);
webResult = envelop.getResponse().toString();
if (webResult != null)
break;
}
} catch (Exception e) {
e.printStackTrace();
Log.e("APP", "ERROR: " + e.getMessage());
}
return webResult;
如果我做错了什么,请纠正我。