我正在尝试在android中使用webservicex.net进行货币转换,使用ksoap2。
然而,它返回0 !! 它甚至不会抛出任何异常,即使我给出错误的参数也只返回0,尽管它使用提供的webservice工作得很好。
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;
如果我做错了,请纠正我。
答案 0 :(得分:0)
我使用了错误的NAME_SPACE,因此无法获取预期的结果。
对我来说,变化不大。
String NAME_SPACE = "http://www.webserviceX.NET/"; // WORKS WITH THIS
String NAME_SPACE = "http://www.webservicex.net/"; // BRINGS 0