如题,我在webservice中的一个登录接口用session保存了一个状态,来判断用户是否登录成功,在web服务提供的其他接口中,我会先判断这个session,然后执行。
但是web服务发布以后,我要在我的网站中调用web服务,登录成功没问题,但是调用其他接口却不行,其他接口判断session为空,然后就返回了。这个问题请前辈们指点。。

解决方案 »

  1.   

     [WebMethod(EnableSession = false)]
        public string Hello1()
        {
            return "Hello," + Session["user"];
        }  
      

  2.   

     
                System.Net.CookieContainer cook = new System.Net.CookieContainer();
                obj.CookieContainer = cook;
     
    obj是websercie的对象
      

  3.   

    在WebService中使用Session要注意
    1、Service端 标示使用 EnableSession = true
    2、Client端要使用ClientCookie保存Cookie
      

  4.   

    如果是ASPNET中调用的话 
    保证是同一个调用对象也可以保证Session不丢因为COOKIE一样
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["ws"] == null)
        {
            MyWebService ws = new MyWebService();
            ws.CookieContainer = new CookieContainer();
            Session["ws"] = ws;
        }
        
        MyWebService ws1 = (MyWebService)Session["ws"];
        //使用 ws1
    }
      

  5.   

    [WebMethod(EnableSession = true)] 
      

  6.   

    在WebService中使用Session要注意 
    1、Service端 标示使用 EnableSession = true 
    2、Client端要使用ClientCookie保存Cookie
    顶!
      

  7.   


    问题是解决了,但是觉得不是很爽,有点繁:在webservice已经确立的情况下,有两个方案:一个是保存web服务的对象;另一个是保存一个password,这样可以不保存web服务的对象,每次先调用登录接口,再调用需要的接口。哪个更好呢?