Page 1 of 1

VLF Web session is not working

Posted: Sun Aug 01, 2021 4:15 am
by Balaji
Hello,

I have created simple Web page which call server which have Session identifier as iii01(See the below code)
Code:
Begin_Com Role(*EXTENDS #PRIM_SRVM) Sessionidentifier('iii01')

Srvroutine Name(FetchUserID) Session(*required)
Field_Map For(*OUTPUT) Field(#std_descl) Parameter_Name(StoredValue)
#std_descl := #Userid
Endroutine

Client side code :-
Mthroutine Name(TestSession)
Define_Com Class(#SessionSrv.TestSessionState) Name(#TestSession)
#io$sts := ""
#Button_Test.Caption := "Testing Session"
#TestSession.ExecuteAsync( #Io$sts )
*
Evtroutine Handling(#TestSession.Completed)
#Com_owner.UpdateSession( True )
#Button_Test.Caption := "Test (Success)"
Endroutine
*
Evtroutine Handling(#TestSession.Failed) Reason(#Reason) Handled(#Handled)
#Handled := True
Case (#Reason)
When (= Unknown)
#Button_Test.Caption := "Test (Failed)"
When (= SessionInvalid)
#Button_Test.Caption := "Test (Session Invalid)"
Endcase
#Com_owner.UpdateSession( False )
Endroutine
Endroutine

every time invalid session.

How to check server session is active or not ?
is Session identifier need to define in web page ?

Re: VLF Web session is not working

Posted: Sun Aug 01, 2021 7:54 am
by Dino
You just need to start the session.

Usually, you start with a dialog asking for the user, password, validate that and if all is good, you start the session.
then, your server routines that require session are enabled.

for example, using some of your code, this could be the web page, notice that in the example I am just starting the session when I start the web page, not really validating it if any condition is ok or not to start it:

Code: Select all

Begin_Com Role(*EXTENDS #PRIM_WEB) Theme(#SYS_THEME<MaterialDesignBlue>)

Define_Com Class(#PRIM_MD.RaisedButton) Name(#Button_test) Caption('PRIMARY') Displayposition(1) Left(64) Parent(#COM_OWNER) Tabposition(1) Themedrawstyle('MediumTitle') Top(36) Width(377)

Evtroutine Handling(#Com_owner.Initialize)
Define_Com Class(#test0731sm.Start) Name(#Startsm)
#Startsm.Execute
Endroutine

Evtroutine Handling(#Button_test.Click)
#COM_OWNER.TestSession
Endroutine

Mthroutine Name(TestSession)
Define_Com Class(#test0731sm.TestSessionState) Name(#TestSession)
#io$sts := ""
#Button_Test.Caption := "Testing Session"
#TestSession.ExecuteAsync( #Io$sts )
*
Evtroutine Handling(#TestSession.Completed)
* #Com_owner.UpdateSession( True )
#Button_Test.Caption := "Test (Success)"
Endroutine
*
Evtroutine Handling(#TestSession.Failed) Reason(#Reason) Handled(#Handled)
#Handled := True
Case (#Reason)
When (= Unknown)
#Button_Test.Caption := "Test (Failed)"
When (= SessionInvalid)
#Button_Test.Caption := "Test (Session Invalid)"
Endcase
* #Com_owner.UpdateSession( False )
Endroutine
Endroutine

End_Com
and this the respective server module:

Code: Select all

Begin_Com Role(*EXTENDS #PRIM_SRVM) Sessionidentifier('iii01')

Srvroutine Name(Start)
* validate user, do something then finally:
#COM_OWNER.StartSession Timeout(3600)
Endroutine

Srvroutine Name(TestSessionState) Session(*REQUIRED)
Field_Map For(*OUTPUT) Field(#IO$STS)
Endroutine

End_Com

Re: VLF Web session is not working

Posted: Mon Aug 02, 2021 4:21 pm
by Balaji
Thanks Dino for reply.

Session start correctly on #Com_owner.Initialize but when i click on #Button_test.Click its give "Test (Session Invalid)" message.

Is any setting needs to be done on server side machine.

Thanks in advance.

Re: VLF Web session is not working

Posted: Tue Aug 03, 2021 7:18 pm
by adale
Baliji,
In the Server Module - Server Routine you have specified = Session(*Required).
In this Server Module or another one that is previously initiated, do you have a "#COM_OWNER.StartSession Timeout(3600)" stated?
Doesn't the session have to be started before you can use session required?
Maybe you already have this, I just don't see it in the code you have shown.
Hope this helps.

Re: VLF Web session is not working

Posted: Wed Aug 04, 2021 4:41 pm
by Balaji
Yes I have started the session on start only.

Srvroutine Name(Start)
#COM_OWNER.StartSession Timeout(3600)
Endroutine

Re: VLF Web session is not working

Posted: Fri Aug 06, 2021 9:59 am
by Dino
Hi Balaji

Please share your complete example, web page and server module, to take a look.

Re: VLF Web session is not working

Posted: Sun Aug 08, 2021 2:22 am
by Balaji
Client Side code :-

Code: Select all

Begin_Com Role(*EXTENDS #PRIM_WEB) Theme(#SYS_THEME<MaterialDesignBlue>) Layoutmanager(#LayoutMain1)

Define_Com Class(#PRIM_VS.Style) Name(#Valid) Backgroundbrush(#Brush1)
Define_Com Class(#PRIM_VS.SolidBrush) Name(#Brush1) Color(ThemeSuccessMedium)

Define_Com Class(#PRIM_VS.Style) Name(#Invalid) Backgroundbrush(#Brush2)
Define_Com Class(#PRIM_VS.SolidBrush) Name(#Brush2) Color(ThemeAccentMedium)


Define_Com Class(#PRIM_TBLO) Name(#LayoutMain1)
Define_Com Class(#PRIM_TBLO.Column) Name(#LayoutMain1Column1) Displayposition(1) Parent(#LayoutMain1)
Define_Com Class(#PRIM_TBLO.Column) Name(#LayoutMain1Column2) Displayposition(2) Parent(#LayoutMain1)
Define_Com Class(#PRIM_TBLO.Column) Name(#LayoutMain1Column3) Displayposition(3) Parent(#LayoutMain1)
Define_Com Class(#PRIM_TBLO.Row) Name(#LayoutMain1Row1) Displayposition(1) Parent(#LayoutMain1)
Define_Com Class(#PRIM_TBLO.Row) Name(#LayoutMain1Row2) Displayposition(2) Parent(#LayoutMain1)
Define_Com Class(#PRIM_TBLO.Row) Name(#LayoutMain1Row3) Displayposition(3) Parent(#LayoutMain1)
Define_Com Class(#PRIM_TBLO.Row) Name(#LayoutMain1Row4) Displayposition(4) Parent(#LayoutMain1)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutMain1Item1) Alignment(TopCenter) Column(#LayoutMain1Column2) Manage(#SignInUser) Parent(#LayoutMain1) Row(#LayoutMain1Row2) Sizing(FitToWidth)

Define_Com Class(#STD_DESCL.EditField) Name(#SignInUser) Displayposition(1) Left(400) Parent(#COM_OWNER) Tabposition(1) Top(200) Caption('Enter a Valid User ID') Width(400) Style(#Invalid)
Define_Com Class(#PRIM_PHBN) Name(#Button_SignOnOff) Caption(' Sign In') Displayposition(2) Left(461) Parent(#COM_OWNER) Tabposition(2) Top(64)
Define_Com Class(#PRIM_PHBN) Name(#Button_Test) Caption('Test Session') Displayposition(3) Left(468) Parent(#COM_OWNER) Tabposition(3) Top(118) Width(293)
Define_Com Class(#PRIM_PHBN) Name(#Button_FetchStored) Caption('Fetch Stored UserID') Displayposition(4) Left(592) Parent(#COM_OWNER) Tabposition(4) Top(64) Width(168)
Define_Com Class(#STD_DESCL.EditField) Name(#StoredUserID) Displayposition(5) Left(120) Parent(#COM_OWNER) Tabposition(5) Top(64) Caption('StoredUserID')
Define_Com Class(#Prim_boln) Name(#SessionActive)
Evtroutine Handling(#Com_owner.Initialize)

Endroutine

Mthroutine Name(Signon) Access(*PRIVATE)
Define_Com Class(#iiiSessionServices.Signin) Name(#Signin)
#Signin.ExecuteAsync( #SignInUser #io$STS )
Evtroutine Handling(#Signin.Completed)
#Com_owner.UpdateSession( (#IO$sts = ok) )
Endroutine
Evtroutine Handling(#Signin.Failed)
#Com_owner.UpdateSession( False )
Endroutine
Endroutine

Mthroutine Name(Signoff) Access(*PRIVATE)
Define_Com Class(#iiiSessionServices.Signoff) Name(#Signoff)
#Signoff.ExecuteAsync
Evtroutine Handling(#Signoff.Completed #Signoff.Failed)
#Com_owner.UpdateSession( False )
Endroutine
Endroutine

Mthroutine Name(UpdateSession) Access(*PRIVATE)
Define_Map For(*INPUT) Class(#Prim_boln) Name(#Active)
#SessionActive := #Active
If (#Active)
#SignInUser.Style <= #Valid
#Button_SignOnOff.Caption := "Sign Off"
Else
#SignInUser.Style <= #Invalid
#Button_SignOnOff.Caption := "Sign On"
Endif
Endroutine

Mthroutine Name(TestSession)
Define_Com Class(#iiiSessionServices.TestSessionState) Name(#TestSession)
#io$sts := ""
#Button_Test.Caption := "Testing Session"
#TestSession.ExecuteAsync( #Io$sts )
*
Evtroutine Handling(#TestSession.Completed)
#Com_owner.UpdateSession( True )
#Button_Test.Caption := "Test (Success)"
Endroutine
*
Evtroutine Handling(#TestSession.Failed) Reason(#Reason) Handled(#Handled)
#Handled := True
Case (#Reason)
When (= Unknown)
#Button_Test.Caption := "Test (Failed)"
When (= SessionInvalid)
#Button_Test.Caption := "Test (Session Invalid)"
Endcase
#Com_owner.UpdateSession( False )
Endroutine
Endroutine


Mthroutine Name(FetchUserID)
Define_Com Class(#iiiSessionServices.FetchUserID) Name(#FetchUserID)
#StoredUserID := *null
#FetchUserID.executeasync( #StoredUserID )
*
Evtroutine Handling(#FetchUserID.completed)
Endroutine
*
Evtroutine Handling(#FetchUserID.failed) Reason(#reason) Handled(#Handled)
#Handled := true
Case (#reason)
When (= Unknown)
#StoredUserID := 'Not available'
When (= SessionInvalid)
#StoredUserID := 'Not available, session invalid'
Endcase
#Com_owner.UpdateSession( False )
Endroutine
Endroutine


Mthroutine Name(SignonOff) Access(*PRIVATE)
If (#SessionActive)
#Com_owner.Signoff
Else
#Com_owner.Signon
Endif
Endroutine


Evtroutine Handling(#Button_FetchStored.Click)
#com_self.FetchUserID
Endroutine
Evtroutine Handling(#Button_Test.Click)
#com_self.TestSession
Endroutine
Evtroutine Handling(#Button_SignOnOff.Click)
#com_self.SignOnOff
Endroutine



End_Com
------------------------------------------------
Server Side Code :-

Code: Select all

Begin_Com Role(*EXTENDS #PRIM_SRVM) Sessionidentifier('iii01')
Define Field(#Userid) Reffld(#std_descl)
Persist Fields(#Userid)
Srvroutine Name(Signin)
Field_Map For(*INPUT) Field(#User)
Field_Map For(*OUTPUT) Field(#io$sts) Parameter_Name(Status)
#User := #User.Uppercase
If (#Com_owner.VerifyUser( #User ))
#Com_owner.StartSession Timeout(100)
#io$sts := OK
#Userid := #User
Else
#io$sts := ER
Endif
Endroutine

Srvroutine Name(Signoff) Session(*Required)
#Com_owner.EndSession
Endroutine

Srvroutine Name(TestSessionState) Session(*Required)
Field_Map For(*OUTPUT) Field(#io$sts) Parameter_Name(Status)
#io$sts := ok
Endroutine

Mthroutine Name(VerifyUser) Access(*PRIVATE)
Define_Map For(*INPUT) Class(#std_descl) Name(#User)
Define_Map For(*RESULT) Class(#prim_boln) Name(#Result)
#Result := (#User = LANSA)
Endroutine

Srvroutine Name(FetchUserID) Session(*required)
Field_Map For(*OUTPUT) Field(#std_descl) Parameter_Name(StoredValue)
#std_descl := #Userid
Endroutine


End_Com

thanks in advance!

Re: VLF Web session is not working

Posted: Sun Aug 08, 2021 5:16 am
by Dino
You just need to change this line in the Mthroutine Signon:

Code: Select all

#Signin.ExecuteAsync( #SignInUser #io$STS )
for

Code: Select all

#Signin.ExecuteAsync( #StoredUserID #io$STS )
then it works fine.

have a great weekend.

Re: VLF Web session is not working

Posted: Mon Aug 09, 2021 10:42 pm
by Balaji
Hi Dino,

Thanks for the reply.

Its still not working.

Re: VLF Web session is not working

Posted: Mon Aug 09, 2021 11:25 pm
by Dino
I have it working here.
According to the logic in your program, you have to type LANSA in capitals in the input field, then click the button to Signin.
the Standard Description turns green.
if you click Test Session will say Test Success.

Attached here a quick export with both programs.

Re: VLF Web session is not working

Posted: Tue Aug 10, 2021 1:02 am
by Balaji
Hi Dino,

its not working for me.

I make copy of you comp and check in.

bit still getting the same error.

Attached here a quick export with both programs.

Re: VLF Web session is not working

Posted: Tue Aug 10, 2021 7:08 am
by Dino
Your quickexport works fine here. You enter LANSA in the input field, click the signin button, then click in test, says Success.
Image

I would think that maybe something is wrong in your LANSA installation, maybe the listener is not working so the server module is not responding to your web page request, maybe a problem with configuration or license, etc?

Can you run the LANSA test http://yourip:yourport/yourlansainstallation/yourpartition/xvlwebtst.html , for example in mine would be: http://localhost:8080/lansa/rho/xvlwebtst.html , click the Send Request to Application Server button, you should get a message saying "The Application Server responded"

If is not working, you will need to first, fix your environment with the assistance of support.

Re: VLF Web session is not working

Posted: Thu Aug 12, 2021 7:04 pm
by Balaji
http://localhost:8080/lansa/rho/xvlwebtst.html its working.

point 1 and point 2 is working but when i click on Test its not working.

what setting i need to check on server ?