我对使用Java的PHP-SOAP-Webservice的SOAP请求有问题(使用Android SDK) 我有一个SOAP-Helper类。此类连接到SOAP-Service并从服务器获取所有原始数据。 在本课程中,我实现了以下方法:
@SuppressWarnings("unchecked")
public static Vector<SoapObject> getLayers(){
try {
final String SOAP_ACTION = "http://www.XYZ.ch/YYY/webservice.php/getLayers";
final String METHOD_NAME = "getLayers";
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.dotNet = true;
soapEnvelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, soapEnvelope);
Vector<SoapObject> result = (Vector<SoapObject>)soapEnvelope.getResponse();
return result;
} catch (Exception e) {
return null;
}
}
然后我有一个从helper-class获取数据的类。这是图层的类。
public void getLayers(){
Vector<SoapObject> vectorLayers = SOAPHelper.getLayers();
ArrayList<HashMap<String, Object>> myList = new ArrayList<HashMap<String, Object>>();
for(int i=0; i<vectorLayers.size(); i++){
HashMap<String, Object> layers = new HashMap<String, Object>();
layers.put("layerId", vectorLayers.get(i).getProperty(0));
layers.put("layerName", vectorLayers.get(i).getProperty(1));
myList.add(layers);
}
}
现在我有这个演员错误:
05-02 13:11:56.866: ERROR/AndroidRuntime(988): Caused by: java.lang.ClassCastException: java.util.Vector
使用调试器,我可以看到Vector中的所有数据。矢量不是空的。所有数据都是正确的。
有什么想法吗?
谢谢 抢劫
答案 0 :(得分:0)
soapEnvelope.getResponse()
返回的对象很可能不是Vector
。尝试使用Collection<SoapObject>
。