我对如何应用 https 和 SAML 来保护 Web 服务有疑问我已经使用 C# 使用 ASP.NET Web 服务应用程序项目实现了 Web 服务,但我必须增强此 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;
}
}
}