Stefan
Well-Known Member
The past few days there has been quite some discussion on encapsulation (on the peg). The following is an excerpt from our documentation on how to talk to our business logic (running on its own AppServer). The business logic temp-tables are exposed to the outside world in a prodataset and therefore violate the encapsulation 'rule'.
To me our interface seems very efficient and clear. What would an alternative interface look like? A temp-table filled with name / value pairs seems kludgy to me?
Introduction
All Exact Financials Enterprise business logic can be invoked on the AppServer. This document describes how to invoke the business logic from a Progress OpenEdge client with a connection to the AppServer.
The following steps are involved:
1. connect
When connecting to the AppServer the user id and password must be passed:
If the connection is succesful a user object is returned as RETURN-VALUE - this must be stored and used for every subsequent call to the AppServer.
If a connection is created to a state-free AppServer, the AppServer connect procedure is not executed upon connecting to the AppServer so an additional call is required to authenticate the user and get the user object
2. request dataset
The AppServer procedure ifall/bl/initialize.p returns a dataset based on the table passed:
The definitions of the dataset can be easily viewed using write-xml:
3. fill temp-tables
Find the temp-table buffers in the dataset using:
4. pass dataset
The next step is to pass the dataset back to the AppServer, calling the remote procedure that contains the action you want to perform. The following business logic actions are supported:
In the above example 'create' can be replaced with 'find', 'update', 'delete', 'search' or 'assign'. If the action failed, lok is set to false and the error temp-table tterrors contains the errors that occurred.
5. disconnect
That's all.
To me our interface seems very efficient and clear. What would an alternative interface look like? A temp-table filled with name / value pairs seems kludgy to me?
Introduction
All Exact Financials Enterprise business logic can be invoked on the AppServer. This document describes how to invoke the business logic from a Progress OpenEdge client with a connection to the AppServer.
The following steps are involved:
- connect
- request dataset
- fill temp-tables
- pass dataset
- disconnect
Code:
DEFINE VARIABLE happserver AS HANDLE NO-UNDO.
DEFINE VARIABLE cuser_object AS CHARACTER NO-UNDO.
DEFINE VARIABLE dsinput AS HANDLE NO-UNDO.
DEFINE VARIABLE dsoutput AS HANDLE NO-UNDO.
DEFINE VARIABLE hbllitem AS HANDLE NO-UNDO.
DEFINE VARIABLE lok AS LOGICAL NO-UNDO.
1. connect
When connecting to the AppServer the user id and password must be passed:
Code:
CREATE SERVER happserver.
hAppServer:CONNECT(
"-URL appserver://server:nameserverport/appservername":U,
"user":U,
"password":U
).
If the connection is succesful a user object is returned as RETURN-VALUE - this must be stored and used for every subsequent call to the AppServer.
Code:
cuser_object = RETURN-VALUE.
If a connection is created to a state-free AppServer, the AppServer connect procedure is not executed upon connecting to the AppServer so an additional call is required to authenticate the user and get the user object
Code:
RUN system/start/appcon.p ON happserver ( "user":U, "password":U, ? ).
cuser_object = RETURN-VALUE.
2. request dataset
The AppServer procedure ifall/bl/initialize.p returns a dataset based on the table passed:
Code:
RUN ifall/bl/initialize.p ON happserver (
cuser_object,
"llitem":U,
OUTPUT DATASET-HANDLE dsinput
).
The definitions of the dataset can be easily viewed using write-xml:
Code:
dsinput:WRITE-XML(
"FILE":U, SUBSTITUTE( "&1&2.xml":U , SESSION:TEMP-DIRECTORY, dsinput:NAME ),
TRUE, ?, ?, TRUE
).
3. fill temp-tables
Find the temp-table buffers in the dataset using:
Code:
hbllitem = dsinput:GET-BUFFER-HANDLE( "tmp-llitem":U ).
hbllitem:BUFFER-CREATE().
ASSIGN
hbllitem::adm_nr = 621
hbllitem::item_code = "new item":U
.
4. pass dataset
The next step is to pass the dataset back to the AppServer, calling the remote procedure that contains the action you want to perform. The following business logic actions are supported:
- create
- find
- update
- delete
- search
- assign
Code:
RUN ifall/bl/create.p ON happserver (
cuser_object, ?, ?,
DATASET-HANDLE dsinput,
OUTPUT DATASET-HANDLE dsoutput,
OUTPUT lok
).
In the above example 'create' can be replaced with 'find', 'update', 'delete', 'search' or 'assign'. If the action failed, lok is set to false and the error temp-table tterrors contains the errors that occurred.
5. disconnect
Code:
DELETE OBJECT dsinput.
DELETE OBJECT dsoutput.
happserverISCONNECT().
DELETE OBJECT happserver.
That's all.