100分问问题!在网上看到好多WEB SERVICE 安全的,但一直没看懂,就是许多人说的在每个Web Services的方法调用时都要传入密码进行验证(通过
有做过的出来讲解下;最好能有实例帖出来看看,
也可发到我的E_MAIL:xiaoguaiboy@163.com --------------------编程问答-------------------- 我也急需这方面的资料,最近研究这个,很郁闷,大家交流,帮忙顶,有资料传我huanglg36@hotmail.com谢谢 --------------------编程问答-------------------- ref:http://www.cnblogs.com/freeliver54/archive/2007/05/29/763546.html --------------------编程问答-------------------- 自己编写SOAP 请求的 内容 --------------------编程问答-------------------- up --------------------编程问答-------------------- 1.新建专案及加入Web服务 WebServiceA
2.在WebServiceA.cs中加入新的public class MySOAPHeader
-----------------------------------------------------
public class MySOAPHeader : System.Web.Services.Protocols.SoapHeader
{
public string UserPWD;
public string UserName;
public bool IsValidUser()
{
string strUserName = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile("userName", "md5");
string strUserPWD = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile("userPWD", "md5");
if ( (UserName == strUserName) && (UserPWD == strUserPWD))
{
return true;
}
else
{
return false;
}
}
}
3.修改WebServiceA的HelloWorld() 添加SoapHeader
----------------------------------------------
/// <summary>
/// WebServiceA 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class WebServiceA : System.Web.Services.WebService {
public WebServiceA ()
{
//如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}
public MySOAPHeader userSOAPHeader ;
[WebMethod, SoapHeader("userSOAPHeader")]
public string HelloWorld()
{
if (userSOAPHeader.IsValidUser())
{
return "Hello World";
}
else
{
return "Sorry";
}
}
}
4.加入Web引用 及 新建测试页面
5.测试页面的按钮事件
-------------------
protected void Button1_Click(object sender, EventArgs e)
{
//
string strUserName = this.txt_UserName.Text.Trim();
strUserName = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(strUserName, "md5");
string strUserPWD = this.txt_UserPWD.Text.Trim();
strUserPWD = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(strUserPWD, "md5");
//
localhost.WebServiceA wsA = new localhost.WebServiceA();
//
localhost.MySOAPHeader userSOAPHeader = new localhost.MySOAPHeader();
userSOAPHeader.UserName = strUserName;
userSOAPHeader.UserPWD = strUserPWD;
//
wsA.MySOAPHeaderValue = userSOAPHeader;
string strReturn = wsA.HelloWorld();
//
this.TextBox1.Text = strReturn;
}
--------------------编程问答-------------------- up --------------------编程问答-------------------- 呵呵,通过SOAPHeader传入用户名和密码。具体http://www.cnblogs.com/fenglin0503/ --------------------编程问答-------------------- 很好,谢谢hm7921936() ( ) 信誉:94 --------------------编程问答-------------------- UP --------------------编程问答-------------------- form认证就行了 --------------------编程问答-------------------- 顶了,在说.SOAPHeader最直观 --------------------编程问答-------------------- 我最近也在研究ws-security的问题,希望同学们一起切磋哦
MSN:mezinzinwish@hotmail.com --------------------编程问答-------------------- jf up 学习 --------------------编程问答-------------------- 可以是用wse3.0。我也没有用过但是这个东西确实不错 --------------------编程问答-------------------- http://www.cnblogs.com/qufo/archive/2007/08/09/849513.html --------------------编程问答-------------------- up --------------------编程问答-------------------- 这个值得研究,记号 --------------------编程问答-------------------- mark --------------------编程问答-------------------- mark 学习 --------------------编程问答-------------------- 看看可以这样不?
传如一个加密串,然后与系统中的加密串核对,通过的就提供服务,否则.... --------------------编程问答-------------------- mark
--------------------编程问答-------------------- 做个极好 --------------------编程问答-------------------- bu cuo ~
补充:.NET技术 , Web Services