
- Forum posts: 2
Sep 24, 2016, 10:47:38 AM via Website
Sep 24, 2016 10:47:38 AM via Website
Hi everyone!
I have a problem. I have a web service written by me on ASP.NET with two WebMethod, both of WebMethod return type is string. In Android Studio, I can just use one of them successfully.
When I use the working method, my code is
SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
result = response.toString();
on the doInBackground() method on AsyncTask class. And then on onPostExecute() method, I can get correct result.
But when I change method like METHOD = "secondMethod"; , my code is same.
But I get an error which is :
FATAL EXCEPTION: AsyncTask #1 java.lang.RuntimeException: An error
occurred while executing doInBackground()
Caused by:
java.lang.ClassCastException: org.ksoap2.serialization.SoapObject
cannot be cast to org.ksoap2.serialization.SoapPrimitive
at
com.example.izm.obsarayuz.MSSQLConnectionAsyncTask.doInBackground(MSSQLConnectionAsyncTask.java:78)
at
com.example.izm.obsarayuz.MSSQLConnectionAsyncTask.doInBackground(MSSQLConnectionAsyncTask.java:27)
at android.os.AsyncTask$2.call(AsyncTask.java:304)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
It says " SoapObject cannot be cast to org.ksoap2.serialization.SoapPrimitive " , but I'm sure returning value or type is string and I must use SoapPrimitive because of it.