/// <summary> /// 动态调用Web Services来实现用户验证 /// </summary> /// <param name="username"></param> /// <param name="password"></param> public ActionResult LoginXml(string username, string password) { if ((username != null && password != null)) { Invokeservers webServers = new Invokeservers(); string webserversUrl = ConfigurationManager.AppSettings["passporturl"].ToString(); string nameSpace = ConfigurationManager.AppSettings["namespace"].ToString(); string className = ConfigurationManager.AppSettings["classname"].ToString(); string actionName = ConfigurationManager.AppSettings["actionname"].ToString(); string apCode = ConfigurationManager.AppSettings["apcode"].ToString(); Global global = new Global(); string userNameTag = "UserName"; string passwordTag = "Password"; string userNameValue = username; string passwordValue = Security.MD5Encrypt(password); string apCodeTag = "Apcode"; string xmlPa = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><Passport></Passport>"; xmlPa = global.CreateSingleTag(xmlPa, userNameTag, userNameValue); xmlPa = global.CreateSingleTag(xmlPa, passwordTag, passwordValue); xmlPa = global.CreateSingleTag(xmlPa, apCodeTag, apCode); object[] Pa = new object[1]; Pa[0] = xmlPa; string result = (string)(webServers.tryWebService(webserversUrl, nameSpace, className, actionName, Pa)); string resultCodeTag = "success"; string resultCodeValue = global.GetSingleTagValue(result, resultCodeTag);//0为成功,-1为不存在此用户,-2密码错误,-3失败 if (resultCodeValue.Trim() == "0") { //登录成功 string resultUserIDTag = "UserID"; string resultUserIDValue = global.GetSingleTagValue(result, resultUserIDTag); } } return View("LoginXml"); }