About us |  Help us improve
intelliVERB - Get a fair search of the Internet !
Visual studio .net
SQL Server
Oracle
Main  >  Web Service  >  Soap header Email this page to friend
Client call
SoapHeader class
Web method Impl.
 
 
 
 
 
C#SoapHeader classTop

  /// <summary>
  /// Authentication class derived from the
  /// SoapHeader class
  /// </summary>

  public class Authentication : SoapHeader
  {
   //Authentication parameters
   public int Client_Id;
   public string Client_Code;
   public string Client_Token;

  }


C#Web method implementationTop

  //Authentication variable to receive the content of the header
  public Authentication Authorization;
  
  [WebMethod]
  //Set both the the Web service and the client as recipient of the SoapHeader
  [SoapHeader("Authorization", Direction=SoapHeaderDirection.InOut)]
  public bool Process_NewEmployee(Employee oEmployee)
  {
   try
   {
    //Authenticate the client service
    //with some database routine

    if (isValidClient(Authorization.Client_Id, Authorization.Client_Code, Authorization.Client_Token))
    {
     //Call create employee routine
    }
    else
    {
     //Log attempt to the system
     return false;
    }
   }
   catch (Exception ex)
   {
    //Log error message
    return false;
   }
   return true;
  }
  //Function in charge of validating the client credentials
  private bool isValidClient(int ClientId,string ClientCode,string ClientToken)
  {
   //Call database query to check client credentials
   //For testing purpose lets validate inputs against constant values

   if ((ClientId==123456)&&
    (ClientCode=="abc123")&&
    (ClientToken=="XDEVGFG-jjgfgfg-1264644-hfgfgfg"))
   {
    //Log query call
    return true;
   }
   else
   {
    //Log failure
    return false;
   }


C#Client callTop

    //TestWS is the web reference to TestWebService
    TestWS.MyWebService MyWS=new TestWS.MyWebService();
    
    //set values for authentication properties
    TestWS.Authentication MyAuthorization=new TestWS.Authentication();
    MyAuthorization.Client_Id=123456;
    MyAuthorization.Client_Code="abc123";
    MyAuthorization.Client_Token="XDEVGFG-jjgfgfg-1264644-hfgfgfg";
    MyWS.AuthenticationValue=MyAuthorization;

    //Create a new employee object
    TestWS.Employee oEmpl = new TestWS.Employee();
    oEmpl.SSN="145-547-8745";
    oEmpl.FirstName="James";
    oEmpl.LastName="Madison";
    //
    //Create a new enmployee

    bool bSuccess=MyWS.Process_NewEmployee(oEmpl);
    if (! bSuccess)
    {
     //Log error processing new employee message
     return;
    }

You last visited
Sql Server Basic functions
XML
DDL Sql Server
Web Objects
 
 
Make a secure donation now with PayPal!