1

I do my work using KSOAP2 to get data from .net WebService. here is my main part in code

private static final String NAMESPACE = "http://tempuri.org/";
private static final String METHOD_NAME = "CountCatalog";
private static final String SOAP_ACTION = NAMESPACE + METHOD_NAME;
private static final String URL = "http://myservice.somee.com/mywebservice.asmx?WSDL";

Code of myAsyncTask:

private class myAsyncTask extends AsyncTask<Void, Void, Void> {

    @Override
    protected void onPostExecute(Void result) {
        // TODO Auto-generated method stub
        super.onPostExecute(result);
        txtcount.setText(reply);
    }

    @Override
    protected void onPreExecute() {
        // TODO Auto-generated method stub
        super.onPreExecute();
    }

    @Override
    protected Void doInBackground(Void... params) {
        // TODO Auto-generated method stub
        try {
            SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet = true;
            envelope.setOutputSoapObject(request);

            HttpsTransportSE httpTransport = new HttpsTransportSE(URL, 0, null, 0);

            httpTransport.call(SOAP_ACTION, envelope);
            SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
            reply = response.toString();
            //txtcount.setText(response.toString());
        } catch (IOException | XmlPullParserException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }


        return null;
    }

}

And using AsyncTask in function:

btncount.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            doCount();
        }
    });
}
private void doCount(){

    myAsyncTask myRequest = new myAsyncTask();
    myRequest.execute();
    }

Here is log errors:

04-20 21:22:38.125: E/AndroidRuntime(277): FATAL EXCEPTION: AsyncTask #1
04-20 21:22:38.125: E/AndroidRuntime(277): java.lang.RuntimeException: An  
04-20 21:22:38.125: E/AndroidRuntime(277):  at java.net.URL.<init>(URL.java:403)
04-20 21:22:38.125: E/AndroidRuntime(277):  at java.net.URL.<init>(URL.java:356)
04-20 21:22:38.125: E/AndroidRuntime(277):  at  org.ksoap2.transport.HttpsServiceConnectionSE.<init>(HttpsServiceConnectionSE.java:51)
    04-20 21:22:38.125: E/AndroidRuntime(277):  at org.ksoap2.transport.HttpsTransportSE.getServiceConnection(HttpsTransportSE.java:47)
04-20 21:22:38.125: E/AndroidRuntime(277):  at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:124)
04-20 21:22:38.125: E/AndroidRuntime(277):  at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:95)
04-20 21:22:38.125: E/AndroidRuntime(277):  at com.example.webservice1.MainActivity$myAsyncTask.doInBackground(MainActivity.java:91)
04-20 21:22:38.125: E/AndroidRuntime(277):  at com.example.webservice1.MainActivity$myAsyncTask.doInBackground(MainActivity.java:1)
04-20 21:22:38.125: E/AndroidRuntime(277):  at android.os.AsyncTask$2.call(AsyncTask.java:185)
04-20 21:22:38.125: E/AndroidRuntime(277):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
Lal
  • 14,726
  • 4
  • 45
  • 70
user3009966
  • 41
  • 1
  • 6
  • what is line no 91 in MainActivity.java? – Lal Apr 20 '15 at 17:19
  • Why is this line not completely shown: `java.lang.RuntimeException: An` it has the main point about the exception. – Stan Apr 20 '15 at 17:31
  • I don't see any name/value pairs being added to the `SoapObject request`, thus, the error is most likely a result of `request` being null. – esme_louise Apr 20 '15 at 17:42
  • this is line no 91:SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); – user3009966 Apr 20 '15 at 18:12

0 Answers0