当前位置: 代码迷 >> Web Service >> 关于webservice,
  详细解决方案

关于webservice,

热度:292   发布时间:2016-05-02 03:06:06.0
关于webservice,急!!!! 在线等
public   class   MyHeader   :   SoapHeader
{
        public   string   Username;
        public   string   Password;
}

[WebService(Namespace   =   "http://tempuri.org/ ")]
[WebServiceBinding(ConformsTo   =   WsiProfiles.BasicProfile1_1)]
public   class   WebService   :   System.Web.Services.WebService
{
        public   WebService   ()  
        {
        }
        //AD   验证用户
        public   bool   validateUser(string   userName,   string   passWord)
        {
                bool   userBool;
                string   un   =   userName;
                string   pw   =   passWord;
                if   (true)
                {
                        HttpCookie   cookie   =   new   HttpCookie( ".BarAuth ");
                        cookie.Value   =   un;
                        cookie.Expires   =   DateTime.Now.AddHours(1);
                        HttpContext.Current.Response.Cookies.Add(cookie);
                        userBool   =   true;
                }
                else
                {
                        userBool   =   false;
                }
                return   userBool;
        }

        //ADUser  
        public   MyHeader   my;
        [WebMethod]
        [SoapHeader( "my ",   Direction   =   SoapHeaderDirection.Out)]
        public   void   ADUser()
        {
                my   =   new   MyHeader();
                if   (HttpContext.Current.Request.Cookies[ ".BarAuth "].Value   !=   null)
                {
                        my.Username   =   HttpContext.Current.Request.Cookies[ ".BarAuth "].Value;
                }                
        }
}
在调用ADUser()出现如下错误:
System.Web.Services.Protocols.SoapException:   服务器无法处理请求

我测试过了,只要吧HttpContext.Current.Request.Cookies[ ".BarAuth "].Value;
  相关解决方案