返回首页

您好,

现在,我面临的困难与Web服务authentication.The客户端请求的Web服务。 firsty,客户端需要用户名和密码登录。然后,服务器将令牌(随机/日期时间/ randomcode)来访问Web服务。客户端可以请求Web服务的令牌密钥。 Web服务需要验证是否是正确的令牌。
现在,以下是我的代码。但我不知道如何继续添加代码,从代码projecet的网络服务身份验证文章。请帮助我!

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.Services;

using System.Web.Services.Protocols;

using System.Text;

 

namespace AuthWebApplication

{

    using System.Security.Cryptography;

 

    /// <summary>

    /// Summary description for WebService1

    /// </summary>

    [WebService(Namespace = "http://tempuri.org/")]

    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

    [System.ComponentModel.ToolboxItem(false)]

    // 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 WebService1 : System.Web.Services.WebService

    {

        public WebService1 ()

        {

 

        //Uncomment the following line if using designed components

        //InitializeComponent();

        }

        //public AuthHeader SoapAuthentication;



        [WebMethod(Description = "A sample Web Method to demonstrate a simple web Service Authentication using SOAP Headers")]

        public string SampleWebMethod(string Username,String Password)

        {

 

       if (Username == "demo" && Password == "123")

       {

              return Username + " is an Authenticated User to access the Web Method";

       }

      else

     {

           return "Access Denied for " + Username;

       }

 

}

最好的问候,
围三月Khaing

回答

评论会员:B 时间:2