Click here to Skip to main content
15,901,666 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Kindly help me in making my this application. I have tried. here is my code..

XML
package com.example.servesh.myapplication;
import android.app.Activity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;


public class Login_Activity extends ActionBarActivity implements View.OnClickListener {

    ConnectionClass connectionClass;
    CallWS CS = new CallWS();
    EditText edtuserid,edtpass;
    Button btnlogin;
    ProgressBar pbbar;
    TextView tvRegisterLink;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login_);

        edtuserid = (EditText) findViewById(R.id.edtuserid);

        edtpass = (EditText) findViewById(R.id.edtpass);
        btnlogin = (Button) findViewById(R.id.btnlogin);
        tvRegisterLink = (TextView) findViewById(R.id.tvRegisterLink);
        tvRegisterLink.setOnClickListener(this);
        pbbar = (ProgressBar) findViewById(R.id.pbbar);
        pbbar.setVisibility(View.GONE);
        btnlogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                DoLogin doLogin = new DoLogin();
                doLogin.execute("");
            }
        });
    }

    public class DoLogin extends AsyncTask<String,String,String>
    {
        String z = "";
        Boolean isSuccess = false;
        String userid = edtuserid.getText().toString();
        String password = edtpass.getText().toString();
        @Override
        protected void onPreExecute() {
            pbbar.setVisibility(View.VISIBLE);
        }
        @Override
        protected void onPostExecute(String r) {
            pbbar.setVisibility(View.GONE);
            Toast.makeText(Login_Activity.this,r,Toast.LENGTH_SHORT).show();
            if(isSuccess) {
                Intent i = new Intent(Login_Activity.this, PADB.class);
                startActivity(i);
                finish();
            }
        }
        @Override
        protected String doInBackground(String... params) {


            if(userid.trim().equals("")|| password.trim().equals(""))
                z = "Please enter User Id and Password";
            else
            {
                try {

                    System.out.println("Returned Connection  "+CS );
                    if (CS == null) {
                        z = "Error in connection with webservice";

                    }
                    else {
                        //String query = "select CustomerId from AccountCustomer";
                       userid = CS.CustomerID( "response");
                        password = CS.Password("response");

                        if(userid.trim().equals("customerID") && password.trim().equals("pass") )
                        {

                            // System.out.println("Result Set OK and firstname is   "+rs.getString(1) );
                            //System.out.println("Result Set OK and lastname is   "+rs.getString(2) );
                            z = "Login successfull";
                            isSuccess=true;
                        }
                        else
                        {
                            //System.out.println("Result Set NOt OK   " );
                            z = "Invalid Credentials";
                            isSuccess = false;
                        }
                    }
                }
                catch (Exception ex)
                {
                    isSuccess = false;
                    z = "Exceptions";
                }
            }
            return z;
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {

            case R.id.tvRegisterLink:
                startActivity(new Intent(this, Register.class));
                break;


        }


    }



}



C#
package com.example.servesh.myapplication;

import android.widget.TextView;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

/**
 * Created by Administrator on 19-11-2015.
 */
public class CallWS {

    public String Password(String password)
    {
        String NAMESPACE = "http://10.1.15.47/Android";
        String URL = " http://alok-pc.intranet.nic.in/Android/customer.svc?wsdl";
        String SOAP_ACTION = "http://10.1.15.47/Android/customer.svc";
        String METHOD_NAME = "Password";

        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);


        String pass = "nic123";

        PropertyInfo passProp =new PropertyInfo();
        passProp.setName("password");
        passProp.setValue(pass);
        passProp.setType(String.class);
        request.addProperty(passProp);

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

        envelope.dotNet = true;
        envelope.setOutputSoapObject(request);
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        SoapPrimitive response = null;
        try
        {
            androidHttpTransport.call(SOAP_ACTION, envelope);
            response = (SoapPrimitive)envelope.getResponse();
            androidHttpTransport.debug = true;

        }
        catch (Exception e)
        {
            e.printStackTrace();


        }
        return androidHttpTransport.responseDump;

    }

    public String CustomerID(String custid)
    {
         String NAMESPACE = "http://10.1.15.47/Android";
         String URL = " http://alok-pc.intranet.nic.in/Android/customer.svc?wsdl";
         String SOAP_ACTION = "http://10.1.15.47/Android/customer.svc";
         String METHOD_NAME = "CustomerID";

        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

        String customerID = "CCBS";


        PropertyInfo custProp =new PropertyInfo();
        custProp.setName("custid");//Define the variable name in the web service method
        custProp.setValue(customerID);//Define value for fname variable
        custProp.setType(String.class);//Define the type of the variable
        request.addProperty(custProp);//Pass properties to the variable




        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

        envelope.dotNet = true;
        envelope.setOutputSoapObject(request);
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        SoapPrimitive response = null;
        try
        {
            androidHttpTransport.call(SOAP_ACTION, envelope);
            response = (SoapPrimitive)envelope.getResponse();
            androidHttpTransport.debug = true;


        }
        catch (Exception e)
        {
            e.printStackTrace();


        }
         return androidHttpTransport.responseDump;
    }

}
Posted

 
Share this answer
 
Comments
Servesh Tiwari 20-Nov-15 5:00am    
I have already tried but confusion occurs. pls help.
i think, you should study about restful service and json because of json and restful will become standard for cross platform
 
Share this answer
 
Comments
Servesh Tiwari 10-Jan-16 8:41am    
thanks... I have consumed the web services successsfully

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900