Page 1 of 1

[SOLVED] VL-WEB - using HTTPHEADER Variables

Posted: Fri Jun 16, 2017 8:25 pm
by RomainM
Hi,

I use an authentification solution that set the user connected in a server HTTP HEADER variable, so I need that the VL-Web page can read this HTTP HEADER Variable.

For WAM, I can map a server HTTP HEADER variable to a field using the LANSAWEB administrator
Image
and it works fine.

I have tried to retrieve the value of this variable with a server module, but it does not work !

How can I read an server HTTP HEADER Variable in a VL-Web page ?

Romain

Re: VL-WEB - using HTTPHEADER Variables

Posted: Sat Jun 17, 2017 1:41 am
by atostaine
I think you use this PRIM_WEB.HttpHeaders. I couldn't find the example I had though.

http://docs.lansa.com/14/en/lansa016/PR ... eaders.htm

HTH

Re: VL-WEB - using HTTPHEADER Variables

Posted: Mon Jun 19, 2017 11:24 pm
by RomainM
Thanks for your answer,

I finally found how to use PRIM_WEB.HttpHeaders:

Code: Select all

Mthroutine Name(uRetrieveHeader)
Define_Com Class(#PRIM_WEB.HttpRequest) Name(#RequestWeb)

#RequestWeb.Url := #SYS_WEB.URL
#RequestWeb.ExecuteAsync

Evtroutine Handling(#RequestWeb.Completed)

For Each(#item) In(#RequestWeb.Response.Headers)
#STD_TEXT := #item.Key
#STD_TEXTL := #item.Value
Add_Entry To_List(#List1)
Endfor

Endroutine

Endroutine
But it needs to send a new request to the server, I would have preferred to retrieve this properties using a #COM_OWNER method! :?

Romain

Re: VL-WEB - using HTTPHEADER Variables

Posted: Tue Jun 20, 2017 12:34 am
by RomainM
Hi,

In fact, it is different than I thought: the header variable is not sent to the browser, so I need to retrieve the HTTP HEADER Variable on the server in a server module (#PRIM_SRVM).

Any ideas?

Romain

Re: VL-WEB - using HTTPHEADER Variables

Posted: Tue Jun 20, 2017 1:55 pm
by MarkD
I am now not sure where you need to access the HTTP request header variables?
On the client in a VL-Web method or on the server in a WAM or Server Module?

Re: VL-WEB - using HTTPHEADER Variables

Posted: Tue Jun 20, 2017 2:24 pm
by MarkD
Also, if it on the server side ........ are you using, or intending to use, a WAM (WEBROUTINE based) or a Server Module (SRVROUTINE based)?

Re: VL-WEB - using HTTPHEADER Variables

Posted: Tue Jun 20, 2017 2:31 pm
by MarkD
If it is on the server - then I think you set up the header variables in the normal way as in first screen shot you pasted.
That should work for WEBROUTINEs and SRVROUTINEs.
In WEBROUTINEs you would then declare matching input WEB_MAPs,
In SRVROUTINEs you would declare matching FIELD_MAPs.

Re: VL-WEB - using HTTPHEADER Variables

Posted: Tue Jun 20, 2017 6:19 pm
by RomainM
Hi,

Thanks for your answer.

I want to build a new VLWeb application.
But the HTTP variable need to be retrieved on the server.


I have define an HTTP Variable using the Web Administrator:
WebAdmin.JPG
WebAdmin.JPG (15.36 KiB) Viewed 22379 times
With the following code, a WAM works OK:

Code: Select all

Webroutine Name(test)
Web_Map For(*both) Fields(#RMCUSRAG)
Endroutine
I have test a VLWeb page with

Code: Select all

Begin_Com Role(*EXTENDS #PRIM_WEB)
Define_Com Class(#RMCUSRAG.Visual) Name(#RMCUSRAG) Componentversion(1) Displayposition(1) Height(21) Left(84) Marginleft(207) Parent(#COM_OWNER) Tabposition(1) Top(54) Usepicklist(False) Width(957)

Evtroutine Handling(#Com_owner.Initialize)

Define_Com Class(#RMCSMHEAD.RecupHeader) Name(#recupheader)

#recupheader.Execute Rmcusrag(#RMCUSRAG)

Endroutine

End_Com
And the Server Module is defined as:

Code: Select all

Begin_Com Role(*EXTENDS #PRIM_SRVM)

Srvroutine Name(RecupHeader)
Field_Map For(*output) Field(#RMCUSRAG)

Endroutine

End_Com
I have tried with Field_Map For(*both) Field(#RMCUSRAG), but it does not work either.

Did I miss something?

Romain

Re: VL-WEB - using HTTPHEADER Variables

Posted: Wed Jun 21, 2017 8:11 am
by MarkD
Sorry but I don't know much about this area.
You restarted the web server after changing the config?
To me it looks like your test VL-Web page is not setting a HTTP header variable.
It's just passing a normal field parameter to the srvroutine, which goes as JSON in the HTTP request body.

Re: VL-WEB - using HTTPHEADER Variables

Posted: Fri Jun 23, 2017 10:58 am
by kelvinlee
That should be Field_Map For(*Input) Field().
*Input means to get the value in.
That can also be *Both if you need the value in Server Module output.

Kelvin

[SOLVED] VL-WEB - using HTTPHEADER Variables

Posted: Fri Jun 23, 2017 5:14 pm
by RomainM
Many thanks Kelvin,

Your answer has helped me to find the solution:
in server module
Srvroutine Name(RecupHeader)
Field_Map For(*input) Field(#RMCUSRAG)
Field_Map For(*output) Field(#wwRMCUSRAG) name(HeaderValue)

define #wwRMCUSRAG reffld(#RMCUSRAG)

#wwRMCUSRAG := #RMCUSRAG
Endroutine
and in VLWeb pag :
#recupheader.Execute HeaderValue(#RMCUSRAG)

Romain

Re: [SOLVED] VL-WEB - using HTTPHEADER Variables

Posted: Thu Jun 29, 2017 11:47 am
by kelvinlee
This should be equivalent to Field_Map For(*Both).
My own test of this does work.
Kelvin