0
回答
Android连接远程Mysql数据库,密码用MD5加密后,出现illegal property
滴滴云服务器,限时包月0.9元,为开发者而生>>>   

用Myeclipse+XFire做一个webservice,然后在Android端用SOAP连接WEBSEVICE,其中用户登录密码是经过MD5加密的,所以在Android端的密码获取是:String Password = CipherUtil.generatePassword(edit02.getText().toString());

然后登录验证如下:

public boolean login(String RefName, String Password) {
boolean result = false;
//实例化SoapObject对象
SoapObject request = new SoapObject(targetNameSpace, getUserByName);
//如果有参数,设置调用参数
request.addProperty("RefName", RefName);
//设置SOAP请求信息(参数部分为SOAP协议版本号,与你调用的WEBSERVICE中的版本号一致)
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = false;
envelope.setOutputSoapObject(request);


try {
envelope.bodyOut = request;
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
envelope.encodingStyle = "UTF-8";


//构建传输对象
HttpTransportSE ht = new HttpTransportSE(WSDL);
ht.debug = true;
//调用webservice
ht.call(targetNameSpace + getUserByName, envelope);

if (envelope.getResponse() != null) {
SoapObject soapObject = (SoapObject) envelope.getResponse();
SoapPrimitive Primitive = (SoapPrimitive) soapObject
.getProperty("Password");

if (Primitive != null) {
if (soapObject.getName() == "anyType") {
// 获取单条的数据
String PWD = Primitive.toString();
if (PWD.equals(Password)) {
result = true;
// 打印登陆信息,还是习惯用sysout,用不惯log
System.out.println("用户" + RefName + "登录成功");
} else {
System.out.println("用户" + RefName + "登录失败,密码错误");
}
}
} else {
System.out.println("用户" + RefName + "不存在");
}
}
} catch (IOException e) {
e.printStackTrace();
} catch (XmlPullParserException e) {
e.printStackTrace();
}


return result;
}


报错如下:

举报
顶部