namespace CheckPassword
{
/// <summary>
/// Summary description for Service1
/// </summary>
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public string CheckPass(string globalid)
{
string conStr1 = System.Configuration.ConfigurationSettings.AppSettings["questConStr"];
string query1 = "select PASSWORD from TM_Roles where GLOBAL_ID='" + globalid + "'";
SqlConnection con1 = new SqlConnection(conStr1);
con1.Open();
SqlCommand command1 = new SqlCommand(query1, con1);
DataSet ds = new DataSet();
SqlDataAdapter oda = new SqlDataAdapter(command1);
oda.Fill(ds, "reading");
DataRow dr = ds.Tables[0].Rows[0];
string password = dr["PASSWORD"].ToString();
string s = password;
/* the next three lines are supposed to remove the xml tags */
System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.BinaryWrite(encoding.GetBytes(s));
con1.Close();
return s;
}
}
}
此方法应该返回密码,不带任何 XML 标记。只是纯文本。上图是从webservice返回的。我怎样才能做到这一点?