The APSV transport enables you to expose server-side ABL business logic to ABL client applications and Java and .NET clients that use the OpenEdge Open Client framework.

To expose ABL business logic through the APSV transport, perform the following steps:

  1. Create a service interface for your business logic.
  2. Place service interface and business logic code in a PROPATH directory.
  3. Test the code using an ABL client.

Create a service interface

A service interface consists of one or more procedure files that provide a layer of abstraction on top of core ABL business logic.

In the following example, the ABL class contains some business logic that needs to be exposed to a client application through the APSV transport.
CLASS Customer: 

    METHOD PUBLIC CHARACTER GetCustomerName(INPUT iCustNum AS INTEGER):

        FIND FIRST Customer WHERE Customer.CustNum = iCustNum.
        IF AVAILABLE Customer THEN
            RETURN Customer.Name.
        ELSE
            RETURN "This customer does not exist".

    END METHOD.    

END CLASS.
The business logic returns a customer's name based on customer ID. To expose this functionality through the APSV transport, you need to create a procedure that acts as a service interface. For example:
DEFINE INPUT PARAMETER iCustNum AS INTEGER NO-UNDO.
DEFINE OUTPUT PARAMETER cName AS CHARACTER NO-UNDO.

DEFINE VARIABLE oCustomer AS Customer NO-UNDO.

oCustomer = new Customer().
cName = oCustomer:GetCustomerName(iCustNum).

Client applications must then run this procedure remotely on a PAS for OpenEdge instance.

Place service interface and business logic code in a PROPATH directory

You must compile service interface and business logic code into r-code and place the r-code in a PROPATH directory to enable client applications to access the code. You can do this in one of the following ways:
  • If you are using Progress Developer Studio for OpenEdge, perform the following steps:
    1. Set automatic compilation by selecting Project > Build Automatically. Alternatively, select Project > Clean.
    2. Right-click the AppServer folder in the project, select Properties, and then click the icon next to the pathname. This opens the folder in a Windows Explorer.
    3. Open the AppServer folder and locate the r-code (files with the extension .R ).
    4. Copy the r-code into a directory that is included in the ABL application's PROPATH.
  • Run a procedure that compiles the ABL business logic and service interface code into a PROPATH directory, as in this example:
    COMPILE C:\Progress\workspace\MyApp\AppServer\Customer.cls SAVE INTO C:\OpenEdge\WRK\oepas1\openedge.
    COMPILE C:\Progress\workspace\MyApp\AppServer\service-interface.p SAVE INTO C:\OpenEdge\WRK\oepas1\openedge.

Test the code using an ABL client

After the compiled ABL code is placed in a PROPATH directory, create an ABL client that runs the service interface procedure remotely. To do this, you need to perform the following steps:
  1. Define variables that map to the service interface's input and output parameters.
    DEFINE VARIABLE CustId AS INTEGER NO-UNDO.
    DEFINE VARIABLE CustName AS CHARACTER NO-UNDO.
    
  2. Create a server object.
    DEFINE VARIABLE hAppServer AS HANDLE NO-UNDO.
    CREATE SERVER hAppServer.
  3. Use the server object to connect to the PAS for OpenEdge instance. You need to specify two properties:
    • -URL—the URL must include the PAS for OpenEdge instance host and port, optionally followed by the name of a web application, followed by the transport name (apsv). If you specify a web application name, ensure that the web application is part of the ABL application whose PROPATH points to your compiled service interface and business logic code.
    • -sessionModel—specify Session-free or Session-managed, based on your needs. Session-free enables unbound connections, where each client request is executed in a separate session. Session-managed enables bound connections, where each client request is executed in the same session, until the DISCONNECT() method is called by the client.
    DEFINE VARIABLE apsvURL AS CHARACTER NO-UNDO.
    apsvURL = "-URL http://localhost:8810/apsv -sessionModel Session-free".
    hAppServer:CONNECT(apsvURL).
    For a complete list of parameters that you can pass to the CONNECT() method, see Connection parameters argument.
  4. Run the service interface procedure.
    CustId = 1.
    RUN service-interface.p ON hAppServer(INPUT CustId, OUTPUT CustName).
    MESSAGE CustName.
    
  5. Disconnect from the server and delete the server object.
    hAppServer:DISCONNECT().
    DELETE OBJECT hAppServer.
Here is the complete example:
DEFINE VARIABLE hAppServer AS HANDLE NO-UNDO.
DEFINE VARIABLE apsvURL AS CHARACTER NO-UNDO. 

DEFINE VARIABLE CustId AS INTEGER NO-UNDO.
DEFINE VARIABLE CustName AS CHARACTER NO-UNDO.

apsvURL = "-URL http://localhost:8810/apsv -sessionModel Session-free".

CREATE SERVER hAppServer.
hAppServer:CONNECT(apsvURL).

CustId = 1.
RUN service-interface.p ON hAppServer(INPUT CustId, OUTPUT CustName).
MESSAGE CustName.

hAppServer:DISCONNECT().
DELETE OBJECT hAppServer.