unit Agent; interface uses SysUtils, ApplicationContext, UserServerService; // Resource strings are stored as resources and linked into the executable or // library so that they can be modified without recompiling the program. resourcestring USER_SERVER_URL = 'http://cacheaccept2010:57772/csp/dev1/WS.Sys.Toegang.UserServer.cls'; APPLICATION_NAME = 'vhintra'; DOMAIN_NAME = '1'; type TAgent = class private FUserServerSoap: UserServerSoap; procedure RegistreerLoginGegevens(UserServerServiceContext: TUserServerServiceContext; pxLogInObj: pxLogIn); procedure RegistreerMislukteLogin(UserServerServiceContext: TUserServerServiceContext; pxStatusObj: pxStatus); public Constructor Create(); overload; procedure GebruikerAanmelden(GebruikersNaam: string; Wachtwoord: string; UserServerServiceContext: TUserServerServiceContext); end; implementation constructor TAgent.Create(); begin FUserServerSoap := UserServerService.GetUserServerSoap(false, USER_SERVER_URL, nil); end; procedure TAgent.GebruikerAanmelden(GebruikersNaam: string; Wachtwoord: string; UserServerServiceContext: TUserServerServiceContext); var LogInData: UserServerService.LogIn; LogInResponseObj: UserServerService.LogInResponse; begin LogInData := nil; LogInResponseObj := nil; try // Request LogInData := UserServerService.LogIn.Create(); LogInData.Application_ := APPLICATION_NAME; LogInData.GebruikersNaam := GebruikersNaam; LogInData.Wachtwoord := Wachtwoord; LogInData.Domein := DOMAIN_NAME; LogInData.pxLogIn := nil; // Ongebruikt LogInResponseObj := FUserServerSoap.LogIn(LogInData); // Response if LogInResponseObj.pxLogIn <> nil then begin // Gelukt RegistreerLoginGegevens(UserServerServiceContext, LogInResponseObj.pxLogIn); end else begin // Mislukt RegistreerMislukteLogin(UserServerServiceContext, LogInResponseObj.LogInResult); end; finally LogInData.Free(); LogInResponseObj.Free(); end; end; procedure TAgent.RegistreerLoginGegevens(UserServerServiceContext: TUserServerServiceContext; pxLogInObj: pxLogIn); begin // Andere velden juist zetten UserServerServiceContext.IsOK := True; UserServerServiceContext.ErrorMessage := ''; UserServerServiceContext.InternalErrorMessage := ''; UserServerServiceContext.SessionKey := pxLogInObj.SessionKey; UserServerServiceContext.GebruikersNaam := pxLogInObj.GebruikersNaam; end; procedure TAgent.RegistreerMislukteLogin(UserServerServiceContext: TUserServerServiceContext; pxStatusObj: pxStatus); begin // Ander velden leegmaken UserServerServiceContext.SessionKey := ''; UserServerServiceContext.GebruikersNaam := ''; UserServerServiceContext.IsOK := pxStatusObj.IsOK; UserServerServiceContext.ErrorMessage := pxStatusObj.Message_; UserServerServiceContext.InternalErrorMessage := pxStatusObj.InternalMessage; end; end.