调用webservice接口 怎么去掉账号密码验证

2025-10-26 11:18:56

1、如果发布的webservice接口,需要账号密码验证,我们改下其代码即可。

调用webservice接口 怎么去掉账号密码验证

2、namespace WebService1

{

    /// <summary>

    /// Service1 的摘要说明

    /// </summary>

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

    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

    [ToolboxItem(false)]

调用webservice接口 怎么去掉账号密码验证

3、   // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。

    // [System.Web.Script.Services.ScriptService]

    public class Service1 : System.Web.Services.WebService

    {

        [WebMethod]

        public string HelloWorld()

        {

            return "Hello World";

        }

     

调用webservice接口 怎么去掉账号密码验证

4、   public  string  show(string  yourname)

        {

            return "http://www.ourfly.com" + "欢迎" + yourname;

        }

        public SqlConnection GetConn()

        {

            SqlConnection conn = new SqlConnection("server=LEAD100SERVER;database=Indagate;uid=lxy;pwd=liu");

            

            return conn;

        }

        public DataTable DBSelect(string sql)

        {

        

调用webservice接口 怎么去掉账号密码验证

5、    SqlDataAdapter sda = new SqlDataAdapter(sql,GetConn());

            DataTable dt = new DataTable();

            sda.Fill(dt);

            return dt;

        }

        public void DBExcute(string sql)

        {

            SqlConnection conn = GetConn();

            conn.Open();

            try

            {

                SqlCommand comm = new SqlCommand(sql,conn);

                comm.ExecuteNonQuery();

            }

            catch

            { 

            }

            conn.Close();

        }

    }

}

调用webservice接口 怎么去掉账号密码验证

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢