开发者

SOAP-Request with Vector, Cast-Error

开发者 https://www.devze.com 2023-03-01 20:59 出处:网络
I\'ve a problem with a SOAP request to a PHP-SOAP-Webservice with Java (with Android SDK) I have a SOAP-Helper class. This class connects to the SOAP-Service and get all raw-data from the server.

I've a problem with a SOAP request to a PHP-SOAP-Webservice with Java (with Android SDK) I have a SOAP-Helper class. This class connects to the SOAP-Service and get all raw-data from the server. In this class i've implemented the following method:

@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;
    }
}

Then I have a class which gets the data from the helper-class. here is the class for the layers.

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).getProp开发者_Python百科erty(0));
        layers.put("layerName", vectorLayers.get(i).getProperty(1));
        myList.add(layers);
    }
}

Now I have this cast error:

05-02 13:11:56.866: ERROR/AndroidRuntime(988): Caused by: java.lang.ClassCastException: java.util.Vector

With the debugger, i see all data in the Vector. The vector isn't empty. All data are correct.

Any ideas?

Thank you rob


Most likely object returned from soapEnvelope.getResponse() is not a Vector. Try just using Collection<SoapObject>.

0

精彩评论

暂无评论...
验证码 换一张
取 消