java.lang.classcastexception - SOAP Fault - 在Android中使用KSOAP2

时间:2012-11-04 00:23:51

标签: web-services classcastexception android-ksoap2

搜索了很多。这些错误的问题在于,尽管文本可能看起来相同,但问题总是不同。

我的服务需要一个字符串值并返回一个字符串响应。这是我的代码:

private class UploadStats extends AsyncTask<String, Void, String>
{
    private static final String WSDL_TARGET_NAMESPACE = "http://tempuri.org/";
    private static final String SOAP_ADDRESS = "http://192.168.1.101/rss/RSS_Service.asmx?WSDL";

    private static final String INSERTURLACTION = "http://192.168.1.101/rss/RSS_Service.asmx/InsertURL";
    private static final String INSERTURLMETHOD = "InsertURL";


    @Override
    protected String doInBackground(String... url)
    {
        String status = "";

        SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,
                INSERTURLMETHOD);

        request.addProperty("url", "www.yahoo.com");
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet = true;

        envelope.setOutputSoapObject(request);
        HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);

        try
        {
            httpTransport.call(INSERTURLACTION, envelope);
            SoapObject response = (SoapObject) envelope.bodyIn;

            status = response.getProperty(0).toString();
        }
        catch (Exception exception)
        {

            Log.d("Error", exception.toString());
        }

        if(status.equals("1"))
        {
            Log.d("InsertURL", "New URL Inserterd");
        }

        else if(status.equals("0"))
        {
            Log.d("InsertURL", "URL Exists. Count incremented");
        }

        else
        {
            Log.d("InsertURL", "Err... No");
        }

        return status;
    }

}

我收到错误: java.lang.classcastexception org.ksoap2.SoapFault

我做错了什么?如果需要更多细节,我可以添加它们。

1 个答案:

答案 0 :(得分:0)

错误与网络服务有关。

服务端的错误命名空间可能导致此错误(许多其他问题也是如此)。

检查的最佳方法是在本地计算机(托管服务的位置)上运行Web服务。