how to Call ksoap web service from android
我想在 android studio 中使用
但我对此还不够承认。
(我总是使用
网址:
http://sms141.ir/sms141_webservice.asmx
我的功能:
1
|
public object[] CheckUsers(string number , string user , string pass)
|
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
private static final String SOAP_ACTION ="http://sms141.ir/CheckUsers"; private static final String METHOD_NAME ="CheckUsers"; private static final String NAMESPACE ="http://sms141.ir"; private static final String URL ="http://sms141.ir/sms141_webservice.asmx"; @Override myAsyncTask myRequest = new myAsyncTask(); } private class myAsyncTask extends AsyncTask<Void, Void, Void> { @Override @Override @Override SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); HttpTransportSE httpTransport = new HttpTransportSE(URL); httpTransport.debug = true; Log.d("App",""+result.getProperty(1).toString()); Log.e("result","0"+response); return null; |
我收到这些错误:
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
> 06-17 18:32:02.751 11495-11515/com.almas.mehr.sms E/AndroidRuntime?1?
> FATAL EXCEPTION: AsyncTask #1 > java.lang.RuntimeException: An error occured while executing doInBackground() > at android.os.AsyncTask$3.done(AsyncTask.java:299) > at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352) > at java.util.concurrent.FutureTask.setException(FutureTask.java:219) > at java.util.concurrent.FutureTask.run(FutureTask.java:239) > at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230) > at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) > at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) > at java.lang.Thread.run(Thread.java:856) > Caused by: java.lang.NullPointerException > at com.almas.mehr.sms.Login$myAsyncTask.doInBackground(Login.java:211) > at com.almas.mehr.sms.Login$myAsyncTask.doInBackground(Login.java:166) > at android.os.AsyncTask$2.call(AsyncTask.java:287) > at java.util.concurrent.FutureTask.run(FutureTask.java:234) > ????????????at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230) > ????????????at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) > ????????????at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) > ????????????at java.lang.Thread.run(Thread.java:856) |
根据我对您的问题的理解,您只需要知道如何将 KSOAP2 库与 android 一起使用来与服务器进行通信。
这是一个链接,您将通过该链接获得实现
http://karanbalkar.com/2014/03/tutorial-78-using-ksoap2-in-android/
如何在android中使用KSoap 2
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/268974.html