我的 Web 服务被调用
public class Service : System.Web.Services.WebService
{
public Service () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
private string password;
[WebMethod]
public void SetPassword(string pPassword)
{
password = pPassword;
}
private bool ValidPassword()
{
return (password == ConfigurationManager.AppSettings["Token"].ToString());
}
[WebMethod]
public DataSet GetAccountInfo(string account)
{
ValidPassword();
//logic here
}
进行调用的网页
Dim mySvc As New RNX.Service
mySvc.SetPassword("passwordhere")
Dim dsAcctInfo As DataSet = mySvc.GetAccountInfo(strAcct)
两种方法都执行得很好... SetPassword 完成,然后使用相同的 Web 服务对象,调用者然后运行 GetAccountInfo,它检查它是否是 ValidPassword()。
但是,此时,变量又为空了……如中,不保留值。