private class MyAsyncTask extends AsyncTask<String,Void,String> { @Override protected String doInBackground(String... params) { SoapObject request = new SoapObject(NAMESPACE,METHOD_NAME); PropertyInfo infoEmail=new PropertyInfo(); infoEmail.setName("authkey"); infoEmail.setType(String.class); infoEmail.setValue(params[0].toString()); request.addProperty(infoEmail); PropertyInfo infoPassword=new PropertyInfo(); infoPassword.setName("username"); infoPassword.setType(String.class); infoPassword.setValue(params[1].toString()); request.addProperty(infoPassword); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.dotNet = true; envelope.setOutputSoapObject(request); HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); try { //Thread.sleep(5000); // AndroidHttpTransport //this is the actual part that will call the webservice androidHttpTransport.call(SOAP_ACTION, envelope); SoapPrimitive resultee=(SoapPrimitive)envelope.getResponse(); System.out.println("Your Soap Based WebService is "+ resultee); // Get the SoapResult from the envelope body. SoapObject result = (SoapObject) envelope.bodyIn; if (result != null) { //Get the first property and change the label text ReturnResult = result.getProperty(0).toString(); //String msg=resultee.toString(); // Toast.makeText(LoginActivity.this, msg, Toast.LENGTH_LONG).show(); } } catch (Exception e) { e.printStackTrace(); return e.toString(); } return ReturnResult; } @Override protected void onPostExecute(String s) { if(s.equalsIgnoreCase("Usercode") && (s.equalsIgnoreCase("Password"))){ Intent MyHomeActivity=new Intent(MainActivity.this,Login.class); MyHomeActivity.putExtra("GetUsername",editTextUsername); startActivity(MyHomeActivity); finish(); } else { Toast.makeText(getApplicationContext(), "User Name or Password inccorret", Toast.LENGTH_LONG).show(); // Hide the progress bar // progressBar.setVisibility(View.GONE); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)