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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
| package com.test.android;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;
import org.ksoap2.transport.HttpTransportSE;
import com.test.android.bnsingg.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class connexion extends Activity implements OnTouchListener {
public Button connex ;
public View.OnClickListener myhandler ;
private static String URL ="http://192.168.2.1:8080/webservice/services/Authentification?wsdl";
private static final String SOAP_ACTION = "http://A/authenticateUserFromDB";
public static final String METHOD_NAME = "authenticateUserFromDB";
public static final String NAMESPACE = "http://A";
public static EditText login ;
public EditText password ;
public AlertDialog.Builder ad ;
public TextView sinscrire ;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.accceuil);
connex = (Button)findViewById(R.id.bb1);
login =(EditText)findViewById(R.id.ed1);
password =(EditText)findViewById(R.id.ed2);
ad = new AlertDialog.Builder(this);
myhandler = new View.OnClickListener() {
public void onClick(View arg0) {
if (connex.getId()==((Button)arg0).getId()){
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
request.addProperty("user",login.getText().toString());
request.addProperty("md",password.getText().toString());
envelope.dotNet=true;
envelope.setOutputSoapObject(request);
AndroidHttpTransport a = new AndroidHttpTransport (URL);
a.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
a.debug = true;
try
{
a.call(SOAP_ACTION, envelope);
String rest = envelope.getResponse().toString();
System.out.println("reponse : "+rest);
if (rest.equals("true")){
ad.setTitle("Authentification");
ad.setMessage("vérification valide");
ad.setPositiveButton("Ok", new android.content.DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
Intent t1 = new Intent(Cofib.this, bnsingg.class);
login =(EditText)findViewById(R.id.ed1);
t1.putExtra("login1", login.getText().toString());
startActivity(t1);
}
}
);
ad.show();
}
else if(rest.equals("false")){
ad.setTitle("Authentification");
ad.setMessage("Password incorrect "+login.getText());
ad.setPositiveButton("Ok", new android.content.DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
password.setText("");
}
}
);
ad.show();
}
}
catch (Exception aE)
{
ad.setMessage(aE.getMessage());
ad.show();
}
}
}
};
connex.setOnClickListener(myhandler);
}
public boolean onTouch(View arg0, MotionEvent arg1) {
return false;
}
public static String valeurr(){
String log=login.getText().toString();
return log;}
} |
Partager