2

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')
Ashish Tikarye
  • 850
  • 8
  • 11
  • Show the logcat output. – K Neeraj Lal Dec 28 '16 at 09:06
  • thanks neeraj for response...here is my logcat java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String org.ksoap2.serialization.SoapPrimitive.toString()' on a null object reference 12-28 14:38:01.454 30805-31137/mls.com.pos W/System.err: at mls.com.pos.Navwebservice_new$AsyncTaskCallWebService.doInBackground(Navwebservice_new.java:177) 12-28 14:38:01.454 30805-31137/mls.com.pos W/System.err: at mls.com.pos.Navwebservice_new$AsyncTaskCallWebService.doInBackground(Navwebservice_new.java:137) – Ashish Tikarye Dec 28 '16 at 09:11
  • Your `result1` variable is null. – K Neeraj Lal Dec 28 '16 at 11:32
  • yes, getting null in result1. but when i debug my code get response null. – Ashish Tikarye Dec 28 '16 at 11:38
  • Try `envelope.debug = true;`. And take the value of `responseDump` and `requestDump`. – K Neeraj Lal Dec 28 '16 at 14:05
  • i was try your solution in HttpTransport but it not works. it gives org.ksoap2.transport.HttpResponseException: HTTP request failed, HTTP status: 401 Error HttpTransportSE androidHttpTransport = new HttpTransportSE(url); androidHttpTransport.call(soap_action, envelope); //SoapObject resultRequestSOAP = (SoapObject) envelope.getResponse(); resultRequestSOAP = (SoapPrimitive) envelope.getResponse(); s = androidHttpTransport.responseDump; k = androidHttpTransport.requestDump; – Ashish Tikarye Dec 29 '16 at 04:35
  • What is the error? – K Neeraj Lal Dec 29 '16 at 04:36
  • DebuggingMode this = {Navwebservice_new$AsyncTaskCallWebService@3728} params = {Void[0]@3732} request = {SoapObject@3733} "Read{}" name = "Read" namespace = "urn:microsoft-dynamics-schemas/page/testcard" properties = {Vector@3740} size = 0 attributes = {Vector@3741} size = 0 shadow$_klass_ = {Class@3613} "class org.ksoap2.serialization.SoapObject" shadow$_monitor_ = -2020652710 envelope = {SoapSerializationEnvelope@3734} ntlm = {NTLMTransport@3735} ntlm.requestDump = null ntlm.responseDump = null soap_action = "urn:microsoft-dynamics-schemas/page/testcard:Read" – Ashish Tikarye Dec 29 '16 at 04:46
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/131760/discussion-between-k-neeraj-lal-and-ashish-tikarye). – K Neeraj Lal Dec 29 '16 at 04:59
  • finally i solved this issue:-) – Ashish Tikarye Jan 20 '17 at 11:33
  • Please post a solution. :) – K Neeraj Lal Jan 20 '17 at 11:50
  • its based on **api** my api in soapui.... `SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); SoapObject soapLogs = new SoapObject(NAMESPACE, ""); soapLogs.addProperty("No", "2"); soapLogs.addProperty("Name", "John"); request.addSoapObject(soapLogs); NtlmTransportt ntlm = new NtlmTransportt(URL, "username", "password", "domain", ""); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); ntlm.call(SOAP_ACTION, envelope); response = (SoapObject) envelope.bodyIn;` – Ashish Tikarye Jan 20 '17 at 12:13

0 Answers0