我貼你我使用的示例代碼使用.NET webservices解析Ksoap2 的結果。我希望它有幫助。
與數據類型,像這樣創建一個類:
import org.ksoap2.serialization.KvmSerializable;
import org.ksoap2.serialization.PropertyInfo;
public class Provincias implements KvmSerializable {
public int GCPRV;
public String GDPRV;
public int GFCTB;
public Provincias(){}
public Provincias(int gcprv, String gdprv, int gfctb)
{
this.GCPRV=gcprv;
this.GDPRV=gdprv;
this.GFCTB=gfctb;
}
@Override
public Object getProperty(int arg0) {
switch(arg0)
{
case 0:
return GCPRV;
case 1:
return GDPRV;
case 2:
return GFCTB;
}
return null;
}
@Override
public int getPropertyCount() {
return 3;
}
@Override
public void getPropertyInfo(int index, Hashtable arg1, PropertyInfo info) {
switch(index)
{
case 0:
info.type = PropertyInfo.INTEGER_CLASS;
info.name = "GCPRV";
break;
case 1:
info.type = PropertyInfo.STRING_CLASS;
info.name = "GDPRV";
break;
case 2:
info.type = PropertyInfo.INTEGER_CLASS;
info.name = "GFCTB";
break;
default:break;
}
}
一旦你有你SoapObject響應,你只需要查詢它的propertis 並將其綁定到類像這樣:
Provincias[] prov = new Provincias[ObjetoSoap.getPropertyCount()];
for (int i = 0; i < prov.length; i++) {
SoapObject pii = (SoapObject)ObjetoSoap.getProperty(i);
Provincias provincia = new Provincias();
provincia.GCPRV=Integer.parseInt(pii.getProperty(0).toString());
provincia.GDPRV =pii.getProperty(1).toString();
provincia.GFCTB=Integer.parseInt(pii.getProperty(2).toString());
prov[i] = provincia;
}
編輯:在這裏你有方法說明:
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Cargar_Provincias_JavaResponse xmlns="http://tempuri.org/">
<Cargar_Provincias_JavaResult>
<Provincias_Class>
<GCPRV>int</GCPRV>
<GDPRV>string</GDPRV>
<GFCTB>int</GFCTB>
</Provincias_Class>
<Provincias_Class>
<GCPRV>int</GCPRV>
<GDPRV>string</GDPRV>
<GFCTB>int</GFCTB>
</Provincias_Class>
</Cargar_Provincias_JavaResult>
</Cargar_Provincias_JavaResponse>
</soap:Body>
</soap:Envelope>
https://www.youtube.com/watch ?V = SN-GNPGDPc8。谷歌它,你會發現很多的例子。至少發佈你迄今爲止所做的事情。粘貼解析代碼。 – Raghunandan
只顯示響應是不夠的。您還應該詳細說明如何解析它。 – Gem