|
//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; }
|