Kbase P18709: How to display error messages for the client from a program
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  04/02/2003 |
|
Status: Unverified
GOAL:
How to display error messages for the client from a program running on the AppServer?
FIX:
Sometimes, even though an Application is being re-written to run on a distributed environment with an AppServer there is a need to preserve some old APIs that are responsible for its business logic. In this case, the code of those old APIs might have some MESSAGE Statements in it, which are not displayed to the end-user's (client) machine. The code below gives a way to workaround this appserver behavior and displays those messages to the client machines:
- Client side:
/*** client.p ***/
DEFINE VARIABLE vhServer AS HANDLE NO-UNDO.
DEFINE VARIABLE vlOK AS LOGICAL NO-UNDO.
CREATE SERVER vhServer.
vlOK = vhServer:CONNECT("-H hostName -S 5162 -AppService asbroker1":U).
IF NOT vlOK THEN
DO:
MESSAGE "Could not connect appserver!"
VIEW-AS ALERT-BOX ERROR.
RETURN.
END.
RUN runOldAPIs.p ON vhServer.
RUN verifyErrorMsgs.p ON vhServer.
IF RETURN-VALUE <> "":U THEN
MESSAGE RETURN-VALUE
VIEW-AS ALERT-BOX ERROR.
vhServer:DISCONNECT().
DELETE OBJECT vhServer.
- AppServer side:
/*** runOldAPIs.p ***/
OUTPUT TO VALUE("errorMsgs.txt":U) KEEP-MESSAGES APPEND.
RUN oldAPI.p.
OUTPUT CLOSE.
/*** oldAPI.p ***/
MESSAGE "Application error from old API" VIEW-AS ALERT-BOX.
/*** verifyErrorMsgs.p ***/
DEFINE VARIABLE vcMessage AS CHARACTER NO-UNDO.
DEFINE VARIABLE vcLongMsg AS CHARACTER NO-UNDO.
INPUT FROM VALUE("errorMsgs.txt":U) APPEND.
REPEAT:
IMPORT UNFORMATTED vcMessage.
ASSIGN vcLongMsg = IF vcLongMsg = "" THEN
vcMessage
ELSE
vcLongMsg + "~n" + vcMessage.
END.
INPUT CLOSE.
RETURN vcLongMsg.