PxPlus User Forum

Main Board => Discussions => Web Services => Topic started by: nmartinez@bristolind.com on August 09, 2022, 01:04:03 PM

Title: Setup EZWeb server on RedHat Linux 8.x Server
Post by: nmartinez@bristolind.com on August 09, 2022, 01:04:03 PM
Hi all,
This is our first time setting up an EZWeb server on a RedHat Linux 8.x server.  We are testing the unsecure connection with port 8080 and when we try to access it via http://192.168.77.201:8080, we get the error shown on the attached file.  We probably still need to do some additional configuration.  Does anyone know what additional steps we are missing?
Our goal for getting setting up this EZWeb server is to be able to integrated one application on our current custom ERP (written in PVXPLUS) to TULIP via (BI-DIRECTIONAL) API calls.
Thank you!



Title: Re: Setup EZWeb server on RedHat Linux 8.x Server
Post by: Mike King on August 10, 2022, 10:29:00 AM
Assumin you have install PxPlus 2022 (v19), please try changing line 92 in *plus/inomads/inomads as follows:

->load "*plus/inomads/inomads"
->list 92
0092 IF reqd_uid$="" THEN RETURN
->92[THEN]=[then UID_SET=1;]
0092 IF reqd_uid$="" THEN LET uid_set=1; RETURN
->save
Title: Re: Setup EZWeb server on RedHat Linux 8.x Server
Post by: nmartinez@bristolind.com on August 10, 2022, 07:17:09 PM
Thank you, Mike!
It now takes me to the iNomads System Administration Functions. 

Is there a technical document that covers each one of these (iNomads system Administration Functions)? 
System Settings -> (TX Maint, Config, Custom)
Template Settings -> (Options, Custom, View/Edit files, Test)
Title: Re: Setup EZWeb server on RedHat Linux 8.x Server
Post by: Mike King on August 15, 2022, 02:57:36 PM
A lot here depends on what you trying to accomplish.  By default the web server will take you to an iNomads configuration page, however from what you described you don't need to use iNomads.

If all you are looking for is to create a web site that will respond to some programmed enquires, then you don't need to use iNomads.

To keep this simple what you can do is create a program with a .pxp suffix and the system will run it in response to a web request.  For example if you want to provide a process that responds to a web request with some part information you might make a program called "parts.pxp".  It can take the part number passed in from the URL and return the part description, Qty on hand, and price.  It would look something like this:

  OPEN (HFN,ERR=Failed) "path_to_part_file"
  READ (LFO,KEY=PartNo$,DOM=Failed) PartNo$,Description$,QtyOnHand,Price
  PRINT (%Print_fn) "AOK"
  PRINT (%Print_fn) Description$
  PRINT (%Print_fn) QtyOnHand
  PRINT (%Print_fn) Price
  END
Failed:
  PRINT (%Print_fn) "Failure:", MSG(err)
  END


Now save that in the program as (parts.pxp) in the directory you are running your web server in.  If using EZWEB and you didn't specify a starting directory in the command line this will be the directory *plus/inomads.  We would suggest you change this by launching EZWeb passing the directory on the command line as follows:

  .../pxplus "*ezweb/server" -arg portNo "" starting_directory

So if you save parts.pxp in /home/myapp/website/parts.pxp your command to launch *EZweb might be:

  .../pxplus "*ezweb/server" -arg 8080 "" /home/myapp/website

Now once you have the server up you should be able to point a browser to:

http://192.168.77.201:8080/parts.pxp?partno=XXXXXXX

Where the server (192.168.77.201) is from the screen shot and details you posted and the XXXXXX is the partno$ value you want your program to receive. 

In response to this request you should have a screen that says "AOK" followed by the part information or "Failure" and the reason.

Now if you want to return the data as JSON (common for intra-application data exchanges) you could put the values you want to pass back into an associative array and use the DIM LIST directive to generate the JSON.  You would then output that to %PRINT_FN and change %CONTENT_TYPE$ to "application/json".

This gives you the basics of using the PxPlus Web server and should get you going.

Title: Re: Setup EZWeb server on RedHat Linux 8.x Server
Post by: nmartinez@bristolind.com on August 15, 2022, 09:23:23 PM
You are awesome!!  Thank you Mike! :)
Title: Re: Setup EZWeb server on RedHat Linux 8.x Server
Post by: nmartinez@bristolind.com on August 16, 2022, 02:39:02 AM
Hi Mike,
I am using Microsoft Edge browser to test a simple program based on your example above but modified to read one of our files.  We are getting the following error message as soon as we type http://192.168.77.201:8080/ltstulip.pxp?id=370

Do you know why we may be getting this error?
Thank you!

Error message starts after next line
========================================
Error has occured:
ERR(Err)............12
ERR(Erx)............120000
ERR(Ret)............258
ERR(OSerr)..........
ERR(Program)......../PXDATA/PROGS/ltstulip.pxp
ERR(EntryPoint).....0
ERR(Stno)...........160
ERR(Obj)............0
ERR(Method).........
ERR(Lfa)............1
ERR(Lfo)............62
ERR(LastPath).......#A
ERR(LastKey)........
ERR(Module).........pvxopn.c
ERR(Line)...........145
--------------------------
! ERR=12, CTL=0, RET=2
! **********************************************************
! Level=1
! PGN="/pxplusweb/lib/_plus/apache/pxp_cgi"
!  Statement......0585
var_fl=62
DIM cgi$:IOLIST ID$
ID$="370"
r$="00001352%DOCUMENT_ROOT$=""/PXDATA/PROGS"""+$0A$+"%DOCUMENT_URL$=$2F6C747374756C69702E707870$"+$0A$+"%HTTP_CONNECTION$=$6B6565702D616C697665$"+$0A$+"%HTTP_UPGRADE_INSECURE_REQUESTS$=$31$"+$0A$+"%HTTP_HOST$=$3139322E3136382E37372E3230313A38303830$"+$0A$+"%HTTP_ACCEPT_LANGUAGE$=$656E2D55532C656E3B713D302E39$"+$0A$+"%HTTP_ACCEPT_ENCODING$=$677A69702C206465666C617465$"+$0A$+"%HTTP_ACCEPT$=$746578742F68746D6C2C6170706C69636174696F6E2F7868746D6C2B786D6C2C6170706C69636174696F6E2F786D6C3B713D302E392C696D6167652F776562702C696D6167652F61706E672C2A2F2A3B713D302E382C6170706C69636174696F6E2F7369676E65642D65786368616E67653B763D62333B713D302E39$"+$0A$+"%HTTP_USER_AGENT$=$4D6F7A696C6C612F352E30202857696E646F7773204E542031302E303B2057696E36343B2078363429204170706C655765624B69742F3533372E333620284B48544D4C2C206C696B65204765636B6F29204368726F6D652F3130342E302E353131322E3831205361666172692F3533372E3336204564672F3130342E302E313239332E3534$"+$0A$+"%PATH_TRANSLATED$=$2F5058444154412F50524F47532F6C747374756C69702E707870$"+$0A$+"%PATH_INFO$=$2F6C747374756C69702E707870$"+$0A$+"%QUERY_STRING$=$69643D333730$"+$0A$+"%REMOTE_IP$=$3139322E3136382E37362E3634$"+$0A$+"%REQUEST_METHOD$=""GET"""+$0A$+"%SERVER_PORT=8080"+$0A$+"%SERVER_ADDR$=""fe80::250:56ff:fea3:aea6%ens192"""+$0A$+"%SERVER_NAME$=$3139322E3136382E37372E3230313A38303830$"+$0A$+"%SERVER_ROOTDIR$=""/PXDATA/PROGS"""+$0A$+"%SERVER_PROTOCOL$=$485454502F312E31$"+$0A$+"%SERVER_SOFTWARE$=""EzWeb/Server"""+$0A$+"%CONTENT_LENGTH=0"+$0A$+"%CONTENT_TYPE$=$$"+$0A$+"%Server_Secure=0"+$0A0A$
url$="/PXDATA/PROGS/ltstulip.pxp"
_x$="%CONTENT_TYPE$"
! ----
! Global variables (%...)
%args=1
%child_timeout=300
%debug=1
%ezweb=1
%print_fn=62
%SERVER_PORT=8080
%time_offset=-700
%true_out=63
DIM %args$[1:1]
%args$[1]="id=370"
%CONTENT_TYPE$="text/html"
%DOCUMENT_ROOT$="/PXDATA/PROGS"
%document_type$=".pxp"
%document_uri$="/ltstulip.pxp"
%DOCUMENT_URL$="/ltstulip.pxp"
%HTTP_ACCEPT$="text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
%HTTP_ACCEPT_ENCODING$="gzip, deflate"
%HTTP_ACCEPT_LANGUAGE$="en-US,en;q=0.9"
%HTTP_CONNECTION$="keep-alive"
%HTTP_HOST$="192.168.77.201:8080"
%HTTP_UPGRADE_INSECURE_REQUESTS$="1"
%HTTP_USER_AGENT$="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.81 Safari/537.36 Edg/104.0.1293.54"
%lang$=".en"
%PATH_INFO$="/ltstulip.pxp"
%PATH_TRANSLATED$="/PXDATA/PROGS/ltstulip.pxp"
%pxpcgi_perform$="start_up.web"
%QUERY_STRING$="id=370"
%REMOTE_IP$="192.168.76.64"
%REQUEST_METHOD$="GET"
%SERVER_ADDR$="fe80::250:56ff:fea3:aea6%ens192"
%server_address$="fe80::250:56ff:fea3:aea6%ens192:8080"
%server_ip$="fe80::250:56ff:fea3:aea6%ens192"
%SERVER_NAME$="192.168.77.201:8080"
%server_port$="8080"
%SERVER_PROTOCOL$="HTTP/1.1"
%SERVER_ROOTDIR$="/PXDATA/PROGS"
%SERVER_SOFTWARE$="EzWeb/Server"
--------------------------
_=/usr/bin/setsid
LANG=en_US.UTF-8
OLDPWD=/
INVOCATION_ID=7f5113ca4d4745de8f039f346c4819eb
PWD=/PXDATA/PROGS
JOURNAL_STREAM=9:32868
TERM=ansi
SHLVL=2
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin

Title: Re: Setup EZWeb server on RedHat Linux 8.x Server
Post by: EVa on August 16, 2022, 02:54:20 AM
And what does line 160 of program ltstulip.pxp look like ?
Title: Re: Setup EZWeb server on RedHat Linux 8.x Server
Post by: Mike King on August 16, 2022, 08:54:26 AM
You appear to be looking for the file/program "#A" as this is in ERR(LastPath). 

File and programs used by your web program need to be accessible by your program.  This could be done using the PREFIX directive to access files/programs external of the directory where your web application is running or  (on Linux) you could using file system links for the files.
Title: Re: Setup EZWeb server on RedHat Linux 8.x Server
Post by: nmartinez@bristolind.com on August 17, 2022, 04:59:50 PM
Thank you !!
Just copied the START_UP program we use with our current ERP  to the starting directory we are using with  EZWeb server.
Our TEST application is working perfectly now thanks to you sir Mike!!
Title: Re: Setup EZWeb server on RedHat Linux 8.x Server
Post by: nmartinez@bristolind.com on August 17, 2022, 06:31:08 PM
Hi Mike,
One last issue we are having.  Our Web Program needs to be able to access data from one of our ERPs (JD Edwards).  The way it has always been done  is by using "[WDX][ODB]" from any of our Windows computers, but the Web Program now resides on our Red Hat LINUX host server and we are using EZWeb.  How do we use DSN/ODBC on this server and this Web Program?  Do we need to install any additional software from PvxPlus, so we can use the ODBC on RedHat Linux?
Thank you!
Title: Re: Setup EZWeb server on RedHat Linux 8.x Server
Post by: Mike King on August 17, 2022, 06:44:57 PM
Well if the database is using SQL Server you might be able to use the Microsoft Linux connector.  Its not the easiest thing to setup but this link should get you started.

https://manual.pvxplus.com/?/PxPlus%20User%20Guide/Data%20Integration/Odbc%20Linking.htm

Basically you need to install unixODBC on your Linux box along with the Microsoft SQL Server ODBC Driver for Linux
Title: Re: Setup EZWeb server on RedHat Linux 8.x Server
Post by: nmartinez@bristolind.com on August 18, 2022, 06:05:30 PM
Hi Mike,
Our JDE ERP's database is using IBM DB2.  We install "IBM System i Navigator Version 7.x " on all Windows computers, so we can choose "iSeries Access ODBC Driver" when creating the ODBC Data Source on the Windows computers (see attached file.)
Thank you.
Title: Re: Setup EZWeb server on RedHat Linux 8.x Server
Post by: Mike King on August 18, 2022, 09:35:12 PM
There is a unixODBC driver for IBM DB2 -- perhaps that might work for you.

http://www.unixodbc.org/doc/db2.html
Title: Re: Setup EZWeb server on RedHat Linux 8.x Server
Post by: nmartinez@bristolind.com on November 08, 2022, 02:17:57 PM
Hi Mike,
Where do you change %CONTENT_TYPE$  to "application/json"?  Is this a parameter to %PRINT_FN?  I looked via pxplus manual and could not find it..
Thank you!

Now if you want to return the data as JSON (common for intra-application data exchanges) you could put the values you want to pass back into an associative array and use the DIM LIST directive to generate the JSON.  You would then output that to %PRINT_FN and change %CONTENT_TYPE$ to "application/json".
Title: Re: Setup EZWeb server on RedHat Linux 8.x Server
Post by: Mike King on November 08, 2022, 03:29:47 PM
You just set the global variable %CONTENT_TYPE$=... in your code that is generating the response.
Title: Re: Setup EZWeb server on RedHat Linux 8.x Server
Post by: nmartinez@bristolind.com on November 08, 2022, 04:03:53 PM

Thank you, Mike!!
Title: Re: Setup EZWeb server on RedHat Linux 8.x Server
Post by: nmartinez@bristolind.com on February 08, 2023, 06:17:11 PM
Hi Mike.. very quick question.. when the program with the .PXP suffix runs, are we able to have a BEGIN Directive  or are we able to CALL other programs with either RUN or CALL or another way?  Just trying to understand if we need to put all the code on the program with the .PXP suffix or we can call other programs..
Thank you!
Title: Re: Setup EZWeb server on RedHat Linux 8.x Server
Post by: Mike King on February 09, 2023, 09:29:05 AM
You should avoid a BEGIN or CLEAR as these will close the connection between the program and the web server and clear all the variables.

You can however do a CALL, PERFORM, or RUN to another program.  Generally for security we suggest you have only a handful of .pxp programs in your document root directory and those will access programs and files in other directories.  This provides additional security as it prevents hackers from trying to run programs they aren't supposed to.

For example, if you look at our web site www.pvxplus.com all the page and program requests are run thru the program pgsrvr.pxp which processes a pg= or tx= parameter on the URL to determine what to do.  The actual web pages, data and logic used by our web site is maintained on a separate directory that is not exposed to the web server. The pgsrvr program validates the request and establishes any environmental settings required.

If you look at Webster+ it too operates in much the same way.  All requests go through webster.pxp and the rest of the application is setup in directories outside the document root and are only accessible by first going through webster.pxp.
Title: Re: Setup EZWeb server on RedHat Linux 8.x Server
Post by: nmartinez@bristolind.com on February 09, 2023, 12:25:55 PM
Thank you very much Mike for the explanation!  It is greatly appreciated!!
Title: Re: Setup EZWeb server on RedHat Linux 8.x Server
Post by: nmartinez@bristolind.com on February 09, 2023, 05:39:23 PM
One last question.. is there a global variable that receives the FULL URL as it gets to the .pxp program.
Example:
If the user types on his browser https://www.pvxplus.com/example.pxp?id=999&wo=1234567

Is there a variable that can be accessed while example.pxp is running?
Thank you!
Title: Re: Setup EZWeb server on RedHat Linux 8.x Server
Post by: Mike King on February 09, 2023, 06:01:39 PM
There is no single variable that has the full URL but you can find the various components of the URL in order to reconstruct it.

Given an example of:   https://www.pvxplus.com/example.pxp?id=999&wo=1234567

%HTTP_HOST$ will have "www.pvxplus.com"
%Document_URI$ will have "/example.pxp"
%Query_String$ will have "id=999&wo=1234567"

You will also be able to determine if you need to prefix with http or https by checking if %server_secure = 1

BTW: A simple trick I use to find all the global variable settings is to create a small PxPlus program called 'dump.pxp' in the root of the site with one line

 0010 A=1/0 ! Divide by zero to force dump


If I want to see what the global settings are I simply change the program name on the URL to dump.pxp and the system will give me a dump of all the global variables and other values that are being passed to my program.
Title: Re: Setup EZWeb server on RedHat Linux 8.x Server
Post by: nmartinez@bristolind.com on February 10, 2023, 12:15:43 PM
Thank you, Mike!!  awesome information!!

Title: Re: Setup EZWeb server on RedHat Linux 8.x Server
Post by: nmartinez@bristolind.com on February 10, 2023, 06:03:32 PM
Hi Mike,
How do we make sure our EZWeb Server is secure?  we are only allowing https, but don't know if there are ways to access the admin configuration section of it.. would like to make sure all holes (if any) are closed. In the document root (the parameter we added when starting the EZWeb Server on the RHEL Linux server) we have only the .pxp file.  My concern is that there might be some way to access the configuration of EZWeb Server by providing something else on the URL that I am not aware of.. 
Sorry for all the questions  :D
Thank you!!