Ksoap调用Webservice - SoapObject的问题

时间:2011-06-20 13:42:00

标签: android web-services ksoap

我正在尝试通过 Ksoap 为我的Android应用调用WSDL Webservice。当我使用SoapPrimitive时,它可以工作,我得到以下字符串:

{"INGREDIENTS": [
    {
        "TEXT": "ohne Schweinefleisch",
        "KEY": "*"
    },
    {
        "TEXT": "mit Alkohol",
        "KEY": "11"
    },

...

等等..我想只有" Text"在ListView,但我不知道如何使用SoapPrimitive实现这一点。

当我使用SoapObject时,我只得到以下的Exeption:

"java.lang.ClassCastException: org.ksoap2.serialization.SoapPrimitive cannot be cast to org.ksoap2.serialization.SoapObject"

这是我的代码:

 try {

        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet=true;
        envelope.setOutputSoapObject(request);

        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        androidHttpTransport.debug = true;
        androidHttpTransport.call(SOAP_ACTION, envelope);

        SoapObject response = (SoapObject)envelope.getResponse();
        }

出了什么问题?我在网上看了几个小时,但我没有找到答案。

1 个答案:

答案 0 :(得分:2)

您的回复看起来像是JSONArray JSONObject。你可以用built-in json library解析它 或使用gson