我收到来自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()。
如何验证用户名&密码是否正确?
答案 0 :(得分:0)
尝试添加以下行:
envelope.implicitTypes= false;
后
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);