'int org.ksoap2.serialization.KvmSerializable.getPropertyCount()' 空对象引用

'int org.ksoap2.serialization.KvmSerializable.getPropertyCount()' on a null object reference

我知道当我连接到互联网时出现此异常但互联网不在服务中的情况,所以我的请求转到服务器上但我无法处理该响应..之后我得到这个例外。

//我得到NullPointerException on response= envelope.getResponse();

class Logintask extends AsyncTask<String, String, String> {


        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            setmainloader(1);

        }

        @Override
        protected String doInBackground(String... args) {

            String NAMESPACE = "URL";
            String URL = "API Call";
            String SOAP_ACTION = "Validate user api";
            String METHOD_NAME = "Some method";

            SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);


            Request.addProperty("TokenID", sm.getUserDetails().get(SessionManager.TOKEN_ID));



            Request.addProperty("UserName", enteredusername);
            Request.addProperty("Pwd", enteredpassword);
            Request.addProperty("GCMID", " ");
            Request.addProperty("Imei", imei);

            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet = true;
            envelope.setOutputSoapObject(Request);
            HttpTransportSE httpTransport = new HttpTransportSE(URL, 20000);

            try {
                httpTransport.call(SOAP_ACTION, envelope);

            } catch (SocketTimeoutException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (XmlPullParserException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            try {


                //CHECK FOR RESPONSE


                Log.d("check for response", "doInBackground: ");

//我在这里遇到异常????当我收到此响应时//连接没有 wifi 或移动数据但没有互联网。

            response=envelope.getResponse();



            //  Log.d("response",response.toString());

        } catch (SoapFault e) {
            // TODO Auto-generated catch block
        }

        return null;
    }

下面是我的日志

FATAL EXCEPTION: AsyncTask #6 Process: com.virtuzoconsultancyservicespvtltd.attendenceapp, PID: 13903 java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask.done(AsyncTask.java:309) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354) at java.util.concurrent.FutureTask.setException(FutureTask.java:223) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at android.os.AsyncTask$SerialExecutor.run(AsyncTask.java:234) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818) Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'int org.ksoap2.serialization.KvmSerializable.getPropertyCount()' on a null object reference at org.ksoap2.serialization.SoapSerializationEnvelope.getResponse(SoapSerializationEnvelope.java:521) at com.vcpl.attendenceappnew.EmailDialog$mailattendance.doInBackground(EmailDialog.java:224) at com.vcpl.attendenceappnew.EmailDialog$mailattendance.doInBackground(EmailDialog.java:175) at android.os.AsyncTask.call(AsyncTask.java:295) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor.run(AsyncTask.java:234)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)  at java.lang.Thread.run(Thread.java:818)

改变这个

 response=envelope.getResponse();

至此

SoapPrimitive response = (SoapPrimitive) envelope.getResponse();