.net C# 调用 XFire发布的Webservice 安全访问控制问题
java
ClientAuthenticationHandler
public void invoke(MessageContext context)
throws Exception
{ Element el = new Element("header");
context.getOutMessage().setHeader(el);
Element auth = new Element("AuthenticationToken");
Element username_el = new Element("Username");
username_el.addContent(username);
Element password_el = new Element("Password");
password_el.addContent(password);
auth.addContent(username_el);
auth.addContent(password_el);
el.addContent(auth);
}
我在asp.net里面的实现步骤完全根据http://blog.csdn.net/myxx520/archive/2009/12/31/5113634.aspx的写法
1. [System.Serializable]
[System.Xml.Serialization.XmlType(Namespace = "我的命名空间")]
[System.Xml.Serialization.XmlRoot(Namespace = "我的命名空间", IsNullable = false)]
public class AuthenticationToken : SoapHeader
{
public string name = "admin";
public string password ="admin";
}
2.在Reference.cs 代理类中加入public AuthenticationToken SoapHeader = new AuthenticationToken();
3.在代理类中web方法上方加入[SoapHeader("SoapHearer")];
4.aspx.cs文件中在page_Load里加入
TestLogin.GuestService guest = new TestLogin.GuestService();
TestLogin.CustomerGet cus = new TestLogin.CustomerGet();
cus = guest.loginGetInterface("aaa", "bbb");
但是执行到guest.loginGetInterface("aaa", "bbb");提示SoapHeaderException:请求必须包含身份验证信息,