'java.lang.String org.ksoap2.serialization.SoapPrimitive.toString()' on a null object

899 views Asked by At

When calling SOAP (wsdl) web service from my app, i faced java.lang.NullPointerException error. these both are java class

NTLMTransport.java

JCIFSEngine.java

Any help would be greatly appreciated

Here is my code

public class AsyncTaskCallWebService extends AsyncTask<Void, Void, Void> {

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        pd.show();
        pd.setMessage("Loading..please wait");
        pd.setCancelable(true);
        pd.setTitle("Callinggg");
    }

    @Override
    protected Void doInBackground(Void... params) {


        String namespace = "urn:microsoft-dynamics-schemas/page/xxxx";
        String url = "http://xx.xxx.xx.xxx:7047/DynamicsNAV/WS/andriod/Page/xxxx";
        String soap_action = "urn:microsoft-dynamics-schemas/page/xxxx:Read";
        String method_name = "Read";
        String great,grt11;


        try {
            SoapObject request = new SoapObject(namespace, method_name);
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet = true;
            envelope.setOutputSoapObject(request);

            NTLMTransport ntlm = new NTLMTransport();
            ntlm.debug = true;
            ntlm.setCredentials(url, "xxxxxxx", "xxxxx", "", "");

            ntlm.call(soap_action, envelope); // Receive Error here!
            SoapObject result = (SoapObject) envelope.getResponse();
            SoapPrimitive result1 = (SoapPrimitive) envelope.getResponse();

           // great = result.toString();
            grt11 = result1.toString();
            //System.out.println(great);
            System.out.println(grt11);

        } catch (Exception e) {
            e.printStackTrace();
            //great = e.toString();
            //System.out.println(great);
            grt11 = e.toString();
            System.out.println(grt11);
        }
          return null;


    }

    @Override
    protected void onPostExecute(Void aVoid) {
        super.onPostExecute(aVoid);
        pd.dismiss();
    }

}

modlue level gradle

 compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile files('libs/jcifs-1.3.18.jar')
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
compile files('libs/ksoap2-android-assembly-3.4.0-jar-with-dependencies.jar')
0

There are 0 answers