我目前正在使用ksoap2网络服务的devoloping和app。 我正在使用“ksoap2-android-assembly-2.6.0-jar-with-dependencies.jar”
这是我的问题。
我可以成功获得有关api10及更低版本的数据。 (*我的 电话和虚拟机)
但当我在Android虚拟机上测试我的应用程序是api 11 更高版本。
HttpTransportSE不起作用。
我的代码;(不是全部)
SoapSerializationEnvelope soapEnvol= new
SoapSerializationEnvelope(SoapEnvelope.VER11);
HttpTransportSE setConn = new HttpTransportSE(URL);
try {
setConn.call(SOAP_ACTION, soapEnvol);
}
catch{Exception e)
{
return null;
}
“”“setConn.call(SOAP_ACTION, soapEnvol);
”“”总是落在上面
api 11 av机器。
我错过了什么? 非常感谢。
编辑:(完整代码回复)
public List<HashMap<String, String>> duyurulariListeOlarakGetir() {
SoapObject istek = new SoapObject(NAMESPACE, METHOD_NAME);
istek.addProperty("user", "123");
istek.addProperty("pass", "123");
istek.addProperty("appID", "1");
SoapSerializationEnvelope soapZarf = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapZarf.dotNet = true;
soapZarf.setOutputSoapObject(istek);
HttpTransportSE baglantıKur = new HttpTransportSE(URL);
List<HashMap<String, String>> fillMaps = new ArrayList<HashMap<String, String>>();
try {
baglantıKur.debug=true;
baglantıKur.call(SOAP_ACTION, soapZarf);
SoapObject sonuclar = (SoapObject) soapZarf.getResponse();
int totalCount = sonuclar.getPropertyCount();
if (totalCount > 0) {
for (int detailCount = 0; detailCount < totalCount; detailCount++) {
SoapObject pojoSoap = (SoapObject) sonuclar.getProperty(detailCount);
HashMap<String, String> map = new HashMap<String, String>();
map.put("duyuruID", pojoSoap.getProperty("duyuruID").toString());
map.put("duyuruMetin", pojoSoap.getProperty("duyuruMetin").toString());
map.put("duyuruSaat", pojoSoap.getProperty("duyuruSaat").toString());
map.put("duyuruBaslik", pojoSoap.getProperty("duyuruBaslik").toString());
map.put("duyuruTarih", pojoSoap.getProperty("duyuruTarih").toString());
map.put("kurumID", pojoSoap.getProperty("duyuruSilindi").toString());
map.put("uygulamaID", pojoSoap.getProperty("duyuruSilindi").toString());
map.put("duyuruSilindi", pojoSoap.getProperty("duyuruSilindi").toString());
fillMaps.add(map);
}
} else
return null;
} catch (Exception e) {
HashMap<String, String> map = new HashMap<String, String>();
map.put("duyuruID", "");
map.put("duyuruMetin", "Bağlantı kurulamadı");
map.put("duyuruSaat", "Bağlantı kurulamadı");
map.put("duyuruBaslik", "Bağlantı kurulamadı");
map.put("duyuruTarih", "Bağlantı kurulamadı");
map.put("kurumID", "Bağlantı kurulamadı");
map.put("uygulamaID","Bağlantı kurulamadı");
map.put("duyuruSilindi", "Bağlantı kurulamadı");
fillMaps.add(map);
return fillMaps;
}
return fillMaps;
}
答案 0 :(得分:1)
这可能与以下事实有关:在apis 11及以上,不允许在主线程中访问网络,你可能必须使用ASYNC任务..我有一个使用JSON对象获取数据的应用程序,我最初编码它只是在onCreate(非常小的代码)..它在我的手机上工作正常..但当我在我的平板电脑(ICS)上尝试它它给了我错误,在调试我看到一个例外,当我用Google搜索它我发现出问题,希望它能帮助你,欢呼!