0

I am working on a app in which i am working with the Soap webservices,i am getting this issue in the day start within my app,i search the solution on internet and try every possible solution but it's not working,now the issue is very annoying for me,please help n thanks in advance for help.also i can share my activity please check wether this is my code fault or the issue is on the server side..

my activity:

    @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);

    ActionBar actionBar = getSupportActionBar();
    actionBar.setLogo(R.drawable.ic_launcher);
    actionBar.setDisplayUseLogoEnabled(true);
    actionBar.setDisplayShowHomeEnabled(true);

    if (android.os.Build.VERSION.SDK_INT > 9) {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
                .permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }

    // errorMsg = (TextView) findViewById(R.id.login_error);

    et_username = (EditText) findViewById(R.id.editText_Mobile);
    et_password = (EditText) this.findViewById(R.id.editText_password);

    btn_signin = (Button) findViewById(R.id.btn_signin);
    btn_create_login = (Button) findViewById(R.id.btn_create_login);
    tv_forgotpass = (TextView) findViewById(R.id.tv_forgotpass);
    tv_login_num = (TextView) findViewById(R.id.tv_login_num);

    prgDialog = new ProgressDialog(this);
    // Set Progress Dialog Text
    prgDialog.setMessage("Please wait...");
    // Set Cancelable as False
    prgDialog.setCancelable(false);

    pDialog = new ProgressDialog(MainActivity.this);

    btn_create_login.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(MainActivity.this,
                    RegisterActivity.class);
            startActivity(intent);
            et_username.setText("");
            et_password.setText("");
        }
    });

    btn_signin.setOnClickListener(new OnClickListener() {

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


}

private void loginAction() {
    request = new SoapObject(NAMESPACE, METHOD_NAME);
    Log.d("SelfCare", "NAMESPACE= " + NAMESPACE);
    Log.d("SelfCare", "METHOD_NAME= " + METHOD_NAME);

    // EditText userName = (EditText) findViewById(R.id.editText1);
    username = et_username.getText().toString();
    // EditText userPassword = (EditText) findViewById(R.id.editText2);
    String user_Password = et_password.getText().toString();
    String apptypecode = "TXDIY0006";

    Log.d("SelfCare", "user_Name= " + username);
    Log.d("SelfCare", "password= " + user_Password);

    /*
     * request.addProperty("username", user_Name);
     * request.addProperty("password", user_Password);
     * request.addProperty("apptypecode", apptypecode);
     */

    // Pass value for userName variable of the web service
    if (username.trim().equals("")) {
        alertDialog("Please Enter Username");
        et_username.requestFocus();
    } else if (user_Password.equals("")) {
        alertDialog("Please Enter Your Password");
        et_password.requestFocus();
    } else {
        PropertyInfo unameProp = new PropertyInfo();
        unameProp.setName("username");// Define the variable name in the web
                                        // service method
        unameProp.setValue(username);// set value for userName variable
        unameProp.setType(String.class);// Define the type of the variable
        request.addProperty(unameProp);// Pass properties to the variable

        // Pass value for Password variable of the web service
        PropertyInfo passwordProp = new PropertyInfo();
        passwordProp.setName("password");
        passwordProp.setValue(user_Password);
        passwordProp.setType(String.class);
        request.addProperty(passwordProp);

        PropertyInfo apptypecodes = new PropertyInfo();
        apptypecodes.setName("apptypecode");
        apptypecodes.setValue(apptypecode);
        apptypecodes.setType(String.class);
        request.addProperty(apptypecodes);

        new AsyncCallWS().execute();
    }

}

private class AsyncCallWS extends AsyncTask<String, Void, Void> {
    @Override
    protected Void doInBackground(String... params) {

        try {

            envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.setOutputSoapObject(request);
            envelope.dotNet = true;
            Log.d("SelfCare", "request= " + request);
            // androidHttpTransport = new HttpTransportSE(URL);
            androidHttpTransport = new HttpTransportSE(URL, 60000);

            Log.d("SelfCare", "androidHttpTransport= "
                    + androidHttpTransport);

            androidHttpTransport.call(SOAP_ACTION, envelope);
            SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
            Log.d("SelfCare", "response= " + response);
            /*
             * Toast.makeText(getApplicationContext(), "Response= " +
             * response, Toast.LENGTH_LONG).show();
             */
            String jsonResponse = "";
            jsonResponse = response.toString();

            // A JSONTokener is needed in order to use JSONObject correctly
            JSONTokener jsonTokener = new JSONTokener(jsonResponse);
            // Pass a JSONTokener to the JSONObject constructor
            JSONObject jsonObj = new JSONObject(jsonTokener);
            JSONArray data = jsonObj.getJSONArray("data");

            if (data != null) {

                // looping through All nodes
                for (int i = 0; i < data.length(); i++) {
                    JSONObject c = data.getJSONObject(i);
                    message = c.getString("message");
                    sessionid = c.getInt("sessionid");
                    saleid = c.getInt("saleid");
                    name = c.getString("name");
                    email = c.getString("email");
                    defaultmsisdn = c.getString("defaultmsisdn");
                    associatedArray = c.getString("AssociatedArray");

                    AssociatedArray.add(associatedArray);

                    Log.d("SelfCare farhan aarray", "AssociatedArray= "
                            + AssociatedArray);



                }

                /*
                 * Toast.makeText(getBaseContext(), "Success",
                 * Toast.LENGTH_LONG).show();
                 */

            } else {
                /*
                 * Toast.makeText(getBaseContext(), "Error",
                 * Toast.LENGTH_LONG) .show();
                 */}

            /*
             * TextView results = (TextView) findViewById(R.id.login_error);
             * results.setText(response.toString());
             */

        } catch (Exception e) {
            // alertDialog(e.toString());
            /*
             * Toast.makeText(getApplicationContext(), e.getMessage(),
             * Toast.LENGTH_LONG).show();
             */
            e.printStackTrace();
        }
        return null;
    }

    @Override
    protected void onPostExecute(Void result) {
        // Log.i(TAG, "onPostExecute");
        // tv.setText(fahren + "° F");

        pDialog.dismiss();

        if (message != null) {

            if (message.equalsIgnoreCase("Login Successful.")) {
                if (defaultmsisdn.equalsIgnoreCase("null") && saleid == 0) {
                    et_username.setText("");
                    et_password.setText("");
                    Intent intent = new Intent(getApplicationContext(),
                            AssociateMsisdn.class);
                    intent.putExtra("username", username);
                    intent.putExtra("sessionid", sessionid);
                    intent.putExtra("name", name);
                    intent.putExtra("email", email);
                    intent.putExtra("AssociatedArray", associatedArray);
                    startActivity(intent);
                    // alertDialog("Open the Associate MSISDN Class.");
                } else {
                    et_username.setText("");
                    et_password.setText("");
                    Intent intent = new Intent(getApplicationContext(),
                            MainMenu.class);
                    intent.putExtra("name", name);
                    intent.putExtra("username", username);
                    intent.putExtra("defaultmsisdn", defaultmsisdn);
                    intent.putExtra("sessionid", sessionid);
                    intent.putExtra("saleid", saleid);
                    intent.putExtra("email", email);
                    intent.putExtra("AssociatedArray", associatedArray);

                    Log.d("SelfCare farhan aarray put", "AssociatedArray= "
                            + AssociatedArray);
                    // intent.putStringArrayListExtra("AssociatedArray",
                    // AssociatedArray);

                    /*
                     * intent.putExtra("associatedmsisdn",
                     * associatedmsisdn);
                     * intent.putExtra("associatedsaleid",
                     * associatedsaleid);
                     * intent.putExtra("associatedmsisdn1",
                     * associatedmsisdn1);
                     * intent.putExtra("associatedsaleid1",
                     * associatedsaleid1);
                     */

                    startActivity(intent);
                }
            } else {
                alertDialog(message);
                // Toast.makeText(getApplicationContext(), "" +message ,
                // Toast.LENGTH_LONG).show();
            }
        } else {
            alertDialog(getResources().getString(R.string.server_error));
        }
    }

    @Override
    protected void onPreExecute() {

        pDialog.setMessage("Logging in ...");
        pDialog.setIndeterminate(false);
        pDialog.setCancelable(false);
        pDialog.show();
    }

    @Override
    protected void onProgressUpdate(Void... values) {
        // Log.i(TAG, "onProgressUpdate");
    }

}
6
  • what is the problem? you set your timeout 60 seconds. androidHttpTransport = new HttpTransportSE(URL, 60000); Commented Mar 16, 2015 at 8:08
  • @RandykaYudhistira dear i set my time out but still it is not working,it is failed and give me the exception Sockettime out.. Commented Mar 16, 2015 at 8:10
  • sockettimeout is where your app reach the timeout you define before but the process is still running. remove your timeout, both in your android and your server and you process will never has sockettimeout exception Commented Mar 16, 2015 at 8:18
  • @RandykaYudhistira dear can u please explain more specifically that what i can do to resolve this bug please. Commented Mar 16, 2015 at 8:26
  • that is not bug by the way. that is the configuration of your connection. Read This SO post Commented Mar 16, 2015 at 8:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.