我收到了来自 soapobject 的 anytype{} 响应。我正在尝试使用 Web 服务传递用户名和密码,但无法获得相同的用户名和密码。请任何身体帮助。
private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL = "http://***.***.*.*/MObile/Logics.asmx";
private static final String LOGIN_METHOD = "CheckLogin";
private static final String SOAP_ACTION_LOGIN = "http://tempuri.org/CheckLogin";
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
setContentView(R.layout.login_layout);
Button signin = (Button) findViewById(R.id.btn_login);
signin.setOnClickListener(this);
}
public void onClick(View v) {
try {
etxt_user = (EditText) findViewById(R.id.txt_username);
etxt_password = (EditText) findViewById(R.id.txt_password);
String username = etxt_user.getText().toString();
String password = etxt_password.getText().toString();
result = (TextView)findViewById(R.id.tv);
SoapObject request = new SoapObject(NAMESPACE, LOGIN_METHOD);
request.addProperty("username",username);
request.addProperty("password",password);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
Log.i("LoginDetail", "Username " + username + "Password " + password);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;
androidHttpTransport.call(SOAP_ACTION_LOGIN, envelope);
SoapObject resultString = (SoapObject)envelope.getResponse();
Log.i("OUTPUT", resultString.toString());
// getting output anytype{}
if(){
}
else{
Toast.makeText(getApplicationContext(), "Wrong U & P", Toast.LENGTH_SHORT).show();
}*/
}
catch (Exception e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(), " Network Exception : " + e
+ "Please check network connectivity.", Toast.LENGTH_LONG).show();
}
}
}
我被这个问题困住了。我想如果用户名密码正确则转到下一个活动,如果错误则 toast.show()。
如何验证用户名和密码是否正确?