gpt4 book ai didi

c# - soapheader认证

转载 作者:太空宇宙 更新时间:2023-11-03 13:55:57 25 4
gpt4 key购买 nike

我无法让我的客户重新调整 Visual Studio 添加到代理类的 AuthHeaderValue我看过很多例子,但找不到任何关于如何解决这个问题的方法。

SOAP 类

     public class AuthHeader : SoapHeader
{
public string Username;
public string Password;

}

网络服务

     public class Service1 : System.Web.Services.WebService
{
public AuthHeader Authentication; ** where does visual studio append value to proxy

[SoapHeader("Authentication", Required = true)]
[WebMethod]
public string security()
{
if (Authentication.Username == "test" &&
Authentication.Password == "test")
{
return "authenticated";
}
else
{
return "get lost";
}
}

客户

   static void Main(string[] args)
{
ServiceReference1.AuthHeader auth = new ServiceReference1.AuthHeader();
auth.Username = "test";
auth.Password = "test";

ServiceReference1.Service1SoapClient ser = new ServiceReference1.Service1SoapClient();
ser.AuthHeaderValue = auth; ** does not reconise authheadervalue
String message = ser.security();
Console.WriteLine(message);

}

最佳答案

您必须将身份验证参数值作为 header 的 TRUE 传递。查看完整解决方案 here

关于c# - soapheader认证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12158545/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com