0

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;
    }

  }
}
4

1 に答える 1

-1

従来のASMXWebサービステクノロジーを使用しています。それは間違いです。

ASMXは新しい開発には使用しないでください。代わりにWCFを使用する必要があります。特に、WCFは、探しているものなどをサポートします。


明確にするために:この答えは「新しいものを使用する」ということではありません。それは「新しいものはあなたが望むことをし、古いものは今よりも何もしない」ということです。

于 2013-02-15T12:21:13.517 に答える