2013-02-15 48 views
0

我对如何将https和SAML应用于安全的Web服务有疑问 我已经实现了使用C#的ASP.NET Web服务应用程序项目的Web服务,但我必须增强此Web服务使用https和SAML的安全Web服务

using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
    using System.Web.Services; 
    using System.Data.SqlClient; 
    using System.Configuration; 

    namespace simpleWeb_services 
    { 
/// <summary> 
/// Summary description for Service1 
/// </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 Service1 : System.Web.Services.WebService 
{ 

    [WebMethod] 
    public string Getinfo(int id) 
    { 
     string name = ""; 

     SqlConnection connection1 = new SqlConnection(); 

     connection1.ConnectionString = 
(username,password)VALUES(' "+ username +" ',"+ password +")", connection); 
     connection1.Open(); 
     SqlCommand cmd = new SqlCommand("SELECT username from [userTable] where 
userid=" + id + "", connection1); 
     SqlDataReader reader = cmd.ExecuteReader(); 
     while (reader.Read()) 
     { 
      name = reader[0].ToString(); 
     } 

     return name; 
    } 

    } 
} 

回答

-1

您正在使用传统的ASMX Web服务技术。这是一个错误。

ASMX不应该用于新的开发。您应该使用WCF来代替。特别是,WCF支持您要查找的内容等等。


需要明确的是:这个答案是不是“使用新的东西,因为它是”。这是关于“新东西做你想要的东西,而旧东西永远不会做比现在更多的事情”。

+0

谢谢你的回答 – 2013-02-15 17:07:56