补充一下。用setA设好值后。再用getA得不到刚设进去的值? [WebMethod] public int getA() { return a; } [WebMethod] public int setA(int Value) { a = Value; return a; } 客户端这样写的 public class Index : System.Web.UI.Page { localhost.Service1 s = new localhost.Service(); } s.setA(100) s.getA() <> 100啊。?怎么回事?
[WebMethod]
public int getA()
{
return a;
}
[WebMethod]
public int setA(int Value)
{
a = Value;
return a;
}
客户端这样写的
public class Index : System.Web.UI.Page
{
localhost.Service1 s = new localhost.Service();
}
s.setA(100)
s.getA() <> 100啊。?怎么回事?
static的可以.NET的XML WebService本质上是远程方法调用,并且每调用一次都在服务端创建一个新的对象
所以成员变量不行的解决办法是使用session:
http://developer.ccidnet.com/pub/disp/Article?columnID=340&articleID=32324&pageNO=1
和Remoting完全不一样
http://blog.csdn.net/lovecherry/archive/2005/03/01/306012.aspx
改用Session是解决方法