如何创建基本认证?

时间:2012-04-02 20:43:23

标签: c# authentication wsdl networkcredentials

[SoapRpcMethod("http://email:password@api-new.begun.ru/index.php?class=AdvertiserService#getProfile", RequestNamespace = "http://email:password@api-new.begun.ru/index.php", ResponseNamespace = "http://email:password@api-new.begun.ru/index.php", Use = System.Web.Services.Description.SoapBindingUse.Literal)]
[return: XmlElement("getProfileReturn")]
public UserProfile getProfile()
{ 
    this.Credentials = new NetworkCredential("email", "password"); // I need basic authication
    object[] results = this.Invoke("getProfile", new object[0]);
    return ((UserProfile)(results[0]));
}

我通过fidller2检查了身份验证:未设置基本

最有趣的是,在同一个班级,所以在这一点上一切都很好:

 [SoapRpcMethodAttribute("http://email:password@api-new.begun.ru/index.php?class=AdvertiserService#auth", RequestNamespace = "http://email:password@api-new.begun.ru/index.php", ResponseNamespace = "http://email:password@api-new.begun.ru/index.php", Use = System.Web.Services.Description.SoapBindingUse.Literal)]
 [return: XmlElement("authReturn")]
 public bool auth(string login, string password, string clientLogin)
 {
    this.Credentials = new NetworkCredential("email", "password");
    object[] results = this.Invoke("auth", new object[] {
                                                         login,
                                                         password,
                                                         clientLogin});
    return ((bool)(results[0]));
 }

0 个答案:

没有答案