Advertisement
Guest User

Untitled

a guest
Apr 5th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. public class AuthHeader : SoapHeader
  2. {
  3. public string Username;
  4. public string Password;
  5.  
  6. }
  7.  
  8. public class Service1 : System.Web.Services.WebService
  9. {
  10. public AuthHeader Authentication; ** where does visual studio append value to proxy
  11.  
  12. [SoapHeader("Authentication", Required = true)]
  13. [WebMethod]
  14. public string security()
  15. {
  16. if (Authentication.Username == "test" &&
  17. Authentication.Password == "test")
  18. {
  19. return "authenticated";
  20. }
  21. else
  22. {
  23. return "get lost";
  24. }
  25. }
  26.  
  27. static void Main(string[] args)
  28. {
  29. ServiceReference1.AuthHeader auth = new ServiceReference1.AuthHeader();
  30. auth.Username = "test";
  31. auth.Password = "test";
  32.  
  33. ServiceReference1.Service1SoapClient ser = new ServiceReference1.Service1SoapClient();
  34. ser.AuthHeaderValue = auth; ** does not reconise authheadervalue
  35. String message = ser.security();
  36. Console.WriteLine(message);
  37.  
  38. }
  39.  
  40. WebService service = new WebService();
  41. service.Authentication.Username = "a";
  42. service.Authentication.Password = "a";
  43. string str = service .CheckAuthn();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement