Soapheader-AuthentifizierungC#

Ein Treffpunkt für C#-Programmierer
Anonymous
 Soapheader-Authentifizierung

Post by Anonymous »

Ich kann meinen Client nicht dazu bringen, AuthHeaderValue zu erkennen, den Visual Studio zur Proxy-Klasse hinzufügt.
Ich habe viele Beispiele gesehen, konnte aber nichts darüber finden, wie ich das Problem lösen kann.

Soap-Klasse

Code: Select all

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

}
Webdienst

Code: Select all

     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";
}
}
Kunde

Code: Select all

   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);

}

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post