[SOLVED] VL-WEB - using HTTPHEADER Variables

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
RomainM
Posts: 19
Joined: Wed May 18, 2016 1:37 am
Location: France

[SOLVED] VL-WEB - using HTTPHEADER Variables

Post 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
Last edited by RomainM on Fri Jun 23, 2017 5:14 pm, edited 1 time in total.
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: VL-WEB - using HTTPHEADER Variables

Post 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
Art Tostaine
RomainM
Posts: 19
Joined: Wed May 18, 2016 1:37 am
Location: France

Re: VL-WEB - using HTTPHEADER Variables

Post 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
RomainM
Posts: 19
Joined: Wed May 18, 2016 1:37 am
Location: France

Re: VL-WEB - using HTTPHEADER Variables

Post 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
MarkD
Posts: 692
Joined: Wed Dec 02, 2015 9:56 am

Re: VL-WEB - using HTTPHEADER Variables

Post 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?
MarkD
Posts: 692
Joined: Wed Dec 02, 2015 9:56 am

Re: VL-WEB - using HTTPHEADER Variables

Post 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)?
MarkD
Posts: 692
Joined: Wed Dec 02, 2015 9:56 am

Re: VL-WEB - using HTTPHEADER Variables

Post 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.
RomainM
Posts: 19
Joined: Wed May 18, 2016 1:37 am
Location: France

Re: VL-WEB - using HTTPHEADER Variables

Post 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 22377 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
MarkD
Posts: 692
Joined: Wed Dec 02, 2015 9:56 am

Re: VL-WEB - using HTTPHEADER Variables

Post 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.
kelvinlee
Posts: 4
Joined: Wed May 25, 2016 5:15 pm

Re: VL-WEB - using HTTPHEADER Variables

Post 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
RomainM
Posts: 19
Joined: Wed May 18, 2016 1:37 am
Location: France

[SOLVED] VL-WEB - using HTTPHEADER Variables

Post 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
kelvinlee
Posts: 4
Joined: Wed May 25, 2016 5:15 pm

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

Post by kelvinlee »

This should be equivalent to Field_Map For(*Both).
My own test of this does work.
Kelvin
Post Reply