ASP.NET web services soap header

From Logic Wiki
Jump to: navigation, search


for authentication or other purposes in server side

public class MyWebService : WebService
{
   public class AuthenticationHandler : SoapHeader
   {
     public string username;
     public string password;
   public AuthenticationHandler Authentication;
   [SoapHeader(Authentication)]
   public int AddUser(....
   {
      if(Authentication == null || Authentication.username != "Bob" || Authentication.password == "test")
    throw new Exception("Can't Login") 

In client side

var auth = new AuthenticationHeader{username = "Bob", password = "test"];
var newTotal = await service.AddProteinAsync(auth, amount, user);