Activity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
t1 = ((EditText) findViewById(R.id.editText1)).getText().toString().trim();
t2 = ((EditText) findViewById(R.id.editText2)).getText().toString().trim();
webAccess();
}
});
}
public void webAccess(){
thread = new Thread(){
public void run(){
try{
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("LoginID",t1);
request.addProperty("Password",t2);
request.addProperty("Token","21220150145");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
System.out.println(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
System.out.println(response);
String xml = response.toString();
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder()
.parse(new InputSource(new StringReader(xml)));
NodeList statNodes = doc.getElementsByTagName("Return"); //parent tag
if (statNodes.getLength() > 0) {
Element stat = (Element)statNodes.item(0);
// System.out.println(stat.getElementsByTagName("status")
// .item(0).getTextContent()); // child tag
Webresponse = stat.getElementsByTagName("status")
.item(0).getTextContent();
}
}
catch(Exception e){
e.printStackTrace();
}
handler.post(createUI);
}
};
thread.start();
}
final Runnable createUI = new Runnable() {
public void run(){
// Toast.makeText(getApplicationContext(),
// Webresponse, Toast.LENGTH_LONG).show();
Intent i=new Intent(CheckLoginActivity.this,HomeActivity.class);
startActivity(i);
}
}
};
}
iam new to soap web service from above code i have done login web service from this if i entered username,password am getting the correct toast message i want to navigate next page how to do that thanks in advance.
如果我输入了正确的密码,我在吐司中获得了成功,我输入了密码,我失败了。
所以我需要的是,如果我输入正确的用户名和密码,它会转到下一页,否则不正确的用户名和密码。所以大家帮我怎么做。
答案 0 :(得分:0)
你必须检查下面的“Webresponse”。
if(Webresponse.equals("success"){
//open target activity
}else{
//show error message
}