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
73
74
75
76
 
public class Login extends Activity {
 private final String NAMESPACE = "http://xcart.com";
    private final String URL = "http://10.0.0.75:8080/XcartLogin/services/Checkemail?wsdl";
    private final String SOAP_ACTION = "http://xcart.com/authentication";
    private final String METHOD_NAME = "authentication";
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login);
        Button login = (Button) findViewById(R.id.btn_login);
        login.setOnClickListener(new View.OnClickListener() {
    
   public void onClick(View arg0) {
    loginAction();
     
   }
  });
    }
     
    private void loginAction(){
     SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
      
        EditText Username = (EditText) findViewById(R.id.tf_userName);
        String login = Username.getText().toString();
        
         
      //Pass value for userName variable of the web service
        PropertyInfo unameProp =new PropertyInfo();
        unameProp.setName("Username");//Define the variable name in the web service method
        unameProp.setValue(login);//set value for userName variable
        unameProp.setType(String.class);//Define the type of the variable
        request.addProperty(unameProp);//Pass properties to the variable
        
     
           
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.setOutputSoapObject(request);
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
         
        try{
            androidHttpTransport.call(SOAP_ACTION, envelope);
               SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
               String status = response.toString();
               TextView result = (TextView) findViewById(R.id.tv_status);
               result.setText(response.toString());

               if(status.equals("Valid Username"))
               {
               
                 Intent intent = new Intent(Login.this,RetailerActivity.class);
                
                 intent.putExtra("Username", login);
                   startActivity(intent);
               }
               else
               {
                 LayoutInflater inflater = getLayoutInflater();
              View layout = inflater.inflate(R.layout.toast_custom_layout,
               (ViewGroup) findViewById(R.id.toast_layout_root));

              Toast toast = new Toast(getApplicationContext());
              toast.setGravity(Gravity.TOP, 0, 30);
              toast.setDuration(Toast.LENGTH_LONG);
              toast.setView(layout);
              toast.show();
               }
        }
        catch(Exception e){
           
        }
       }
     
}