1

找了好久。这些错误的问题在于,虽然文本可能看起来相同,但问题总是不同的。

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

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

我究竟做错了什么?如果需要更多详细信息,我可以添加它们。

4

1 回答 1

0

该错误与 Web 服务有关。

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

最好的检查方法是在本地机器(托管服务的地方)上运行 web 服务。

于 2013-01-07T06:09:57.310 回答