{"id":7351,"date":"2014-06-07T02:30:16","date_gmt":"2014-06-07T02:30:16","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/06\/07\/ksoap-2-communication-sending-the-asynctask-result-to-ui-thread-and-print-collection-of-common-programming-errors\/"},"modified":"2014-06-07T02:30:16","modified_gmt":"2014-06-07T02:30:16","slug":"ksoap-2-communication-sending-the-asynctask-result-to-ui-thread-and-print-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/06\/07\/ksoap-2-communication-sending-the-asynctask-result-to-ui-thread-and-print-collection-of-common-programming-errors\/","title":{"rendered":"ksoap 2 communication &#8211; sending the asynctask result to UI thread and print-Collection of common programming errors"},"content":{"rendered":"<p>I am trying to send the login credentials from android user to a C# web service running in my local host through visual studio. I have used KSOAP2 for the SOAP communication and wanted to send the login info to the web service and print it in the UI. I am using AsyncTask to do it but was unable to get the information from the web service and print it to android UI.<\/p>\n<p>Can some one please help where I went wrong ?????<\/p>\n<pre><code>public class MainActivity extends Activity {\n\n    EditText un,pw;\n    TextView tv;\n    Button test;\n    \/** Called when the activity is first created. *\/\n    @Override\n    public void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n        Button test=(Button) findViewById(R.id.login);\n        un = (EditText) findViewById(R.id.et_un);\n        pw = (EditText) findViewById(R.id.et_pw);\n\n\n            test.setOnClickListener(new View.OnClickListener(){\n\n                @Override\n                public void onClick(View v) {\n                    FileAsync fleasyn= new FileAsync(null);\n                    fleasyn.execute();\n                    } \n                }); \n }\n}\n\n\n\nclass FileAsync extends AsyncTask {\n   public FileAsync(String quotes) \n{\n\n\n}\n\n\nprivate char[] resultstring;\nprivate TextView tv;\n\n@Override\nprotected void onProgressUpdate(String... progress) {\n\n\n}\n\nprotected void onPostExecute(String unused) {\n    tv.setText(\"Status:\"+resultstring);\n                System.out.println(resultstring);\n}\n\n\n@Override\nprotected char[] doInBackground(String... params) {\n\n    final String NAMESPACE = \"http:\/\/sparking.org\/login\";\n    final String METHOD_NAME = \"login\";\n    final String SOAP_ACTION = \"http:\/\/sparking.org\/login\";\n    final String URL = \"http:\/\/localhost:63734\/service.asmx\";\n\n    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);\n\n    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);\n    envelope.dotNet = true;\n    envelope.setOutputSoapObject(request);\n    HttpTransportSE transport = new HttpTransportSE(URL);\n    try {\n    transport.call(SOAP_ACTION, envelope);\n    SoapPrimitive resultstring = (SoapPrimitive)envelope.getResponse();\n\n}\n\n    catch (Exception e)\n    {\n        e.printStackTrace();\n    } \n    return resultstring;\n\n}\n<\/code><\/pre>\n<p>ERROR MESSAGES:<\/p>\n<pre><code>04-30 04:46:14.689: I\/System.out(2453): waiting for debugger to settle...\n04-30 04:46:14.885: I\/System.out(2453): waiting for debugger to settle...\n04-30 04:46:15.086: I\/System.out(2453): debugger has settled (1399)\n04-30 04:49:00.905: W\/System.err(2453): java.net.SocketException: socket failed: EACCES (Permission denied)\n04-30 04:49:00.925: W\/System.err(2453):     at libcore.io.IoBridge.socket(IoBridge.java:583)\n04-30 04:49:00.935: W\/System.err(2453):     at java.net.PlainSocketImpl.create(PlainSocketImpl.java:201)\n04-30 04:49:00.945: W\/System.err(2453):     at java.net.Socket.checkOpenAndCreate(Socket.java:663)\n04-30 04:49:00.955: W\/System.err(2453):     at java.net.Socket.connect(Socket.java:807)\n04-30 04:49:00.975: W\/System.err(2453):     at libcore.net.http.HttpConnection.(HttpConnection.java:76)\n04-30 04:49:00.975: W\/System.err(2453):     at libcore.net.http.HttpConnection.(HttpConnection.java:50)\n04-30 04:49:01.035: W\/System.err(2453):     at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340)\n04-30 04:49:01.075: W\/System.err(2453):     at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)\n04-30 04:49:01.155: W\/System.err(2453):     at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)\n04-30 04:49:01.166: W\/System.err(2453):     at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:316)\n04-30 04:49:01.185: W\/System.err(2453):     at libcore.net.http.HttpEngine.connect(HttpEngine.java:311)\n04-30 04:49:01.185: W\/System.err(2453):     at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:290)\n04-30 04:49:01.205: W\/System.err(2453):     at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:240)\n04-30 04:49:01.215: W\/System.err(2453):     at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:81)\n04-30 04:49:01.225: W\/System.err(2453):     at org.ksoap2.transport.ServiceConnectionSE.connect(ServiceConnectionSE.java:46)\n04-30 04:49:01.245: W\/System.err(2453):     at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:68)\n04-30 04:49:01.255: W\/System.err(2453):     at com.example.cmpe220.FileAsync.doInBackground(MainActivity.java:171)\n04-30 04:49:01.265: W\/System.err(2453):     at com.example.cmpe220.FileAsync.doInBackground(MainActivity.java:1)\n04-30 04:49:01.275: W\/System.err(2453):     at android.os.AsyncTask$2.call(AsyncTask.java:287)\n04-30 04:49:01.285: W\/System.err(2453):     at java.util.concurrent.FutureTask.run(FutureTask.java:234)\n04-30 04:49:01.305: W\/System.err(2453):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)\n04-30 04:49:01.325: W\/System.err(2453):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)\n04-30 04:49:01.345: W\/System.err(2453):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)\n04-30 04:49:01.345: W\/System.err(2453):     at java.lang.Thread.run(Thread.java:856)\n04-30 04:49:01.365: W\/System.err(2453): Caused by: libcore.io.ErrnoException: socket failed: EACCES (Permission denied)\n04-30 04:49:01.545: W\/System.err(2453):     at libcore.io.Posix.socket(Native Method)\n04-30 04:49:01.758: W\/System.err(2453):     at libcore.io.BlockGuardOs.socket(BlockGuardOs.java:181)\n04-30 04:49:01.765: W\/System.err(2453):     at libcore.io.IoBridge.socket(IoBridge.java:568)\n04-30 04:49:01.777: W\/System.err(2453):     ... 23 more\n04-30 04:50:13.456: W\/System.err(2453): java.net.SocketException: socket failed: EACCES (Permission denied)\n04-30 04:50:13.465: W\/System.err(2453):     at libcore.io.IoBridge.socket(IoBridge.java:583)\n04-30 04:50:13.476: W\/System.err(2453):     at java.net.PlainSocketImpl.create(PlainSocketImpl.java:201)\n04-30 04:50:13.485: W\/System.err(2453):     at java.net.Socket.checkOpenAndCreate(Socket.java:663)\n04-30 04:50:13.496: W\/System.err(2453):     at java.net.Socket.connect(Socket.java:807)\n04-30 04:50:13.505: W\/System.err(2453):     at libcore.net.http.HttpConnection.(HttpConnection.java:76)\n04-30 04:50:13.517: W\/System.err(2453):     at libcore.net.http.HttpConnection.(HttpConnection.java:50)\n04-30 04:50:13.525: W\/System.err(2453):     at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340)\n04-30 04:50:13.545: W\/System.err(2453):     at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)\n04-30 04:50:13.555: W\/System.err(2453):     at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)\n04-30 04:50:13.575: W\/System.err(2453):     at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:316)\n04-30 04:50:13.585: W\/System.err(2453):     at libcore.net.http.HttpEngine.connect(HttpEngine.java:311)\n04-30 04:50:13.605: W\/System.err(2453):     at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:290)\n04-30 04:50:13.615: W\/System.err(2453):     at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:240)\n04-30 04:50:13.625: W\/System.err(2453):     at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:81)\n04-30 04:50:13.635: W\/System.err(2453):     at org.ksoap2.transport.ServiceConnectionSE.connect(ServiceConnectionSE.java:46)\n04-30 04:50:13.655: W\/System.err(2453):     at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:68)\n04-30 04:50:13.665: W\/System.err(2453):     at com.example.cmpe220.FileAsync.doInBackground(MainActivity.java:171)\n04-30 04:50:13.685: W\/System.err(2453):     at com.example.cmpe220.FileAsync.doInBackground(MainActivity.java:1)\n04-30 04:50:13.715: W\/System.err(2453):     at android.os.AsyncTask$2.call(AsyncTask.java:287)\n04-30 04:50:13.776: W\/System.err(2453):     at java.util.concurrent.FutureTask.run(FutureTask.java:234)\n04-30 04:50:13.845: W\/System.err(2453):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)\n04-30 04:50:13.855: W\/System.err(2453):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)\n04-30 04:50:13.875: W\/System.err(2453):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)\n04-30 04:50:13.875: W\/System.err(2453):     at java.lang.Thread.run(Thread.java:856)\n04-30 04:50:13.885: W\/System.err(2453): Caused by: libcore.io.ErrnoException: socket failed: EACCES (Permission denied)\n04-30 04:50:13.915: W\/System.err(2453):     at libcore.io.Posix.socket(Native Method)\n04-30 04:50:13.925: W\/System.err(2453):     at libcore.io.BlockGuardOs.socket(BlockGuardOs.java:181)\n04-30 04:50:13.945: W\/System.err(2453):     at libcore.io.IoBridge.socket(IoBridge.java:568)\n04-30 04:50:13.965: W\/System.err(2453):     ... 23 more\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I am trying to send the login credentials from android user to a C# web service running in my local host through visual studio. I have used KSOAP2 for the SOAP communication and wanted to send the login info to the web service and print it in the UI. I am using AsyncTask to do [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7351","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7351","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7351"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7351\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7351"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7351"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7351"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}