Proxygen Example

rherring

New Member
Hi,

Using Progress 10.2A I am trying to create a very simple Java to App Server program. Basically, a stub program to see if I can get all the connections to work.

The only example I could find was for the Accounting example for a persistent procedure. Maybe it's because my Java knowledge is lite (okay, non-existent), but the example is terrible. The documentation talks about the App Object and the SubAppObject. The SubAppObject is described but there is never an example or a description of WHY you would use it.

1) If anyone could tell me what the SubAppObject is for, I would be very grateful.
2) If there was a very simple example of passing the SQL result set to a temp table that would be a great help as well.

I created and ran a simple Progress program through the ProxyGen. No issues generating it or seeing the classes. I used Eclipse and pulled in the Progress classes and the ones I generated. No dice. I found the example below and I going to try to use it as a test.


thanks and regards,

Rich




DEF INPUT PARAMETER ipKillAgendaNo AS INT.
DEFINE OUTPUT PARAMETER pout AS INT.
pout = ipKillAgendaNo + 10.

AppObj and AppObjImp generated by proxygen is ProObject.

If you compile thiis procedure as nonpersistent using proxy generator yor client code is:

import com.progress.open4gl.*;
import java.io.*;
public class TestClient {
public TestClient() {
}
public static void main(String[] args) {
AppObj appObj = null;
IntHolder inth = new IntHolder();
try {
appObj = new AppObj("AppServer://localhost/tested" , "sysprogress", "ADMINISTRATOR", "");
appObj.KillAgendaInfo(1,inth);
System.out.println(inth.getIntValue());
} catch (Exception e1) {
// ignore
}
}
}
 
Since 10.C no longer need to proxy-gen, you can use a direct connection
to appServer, is more easy, here you find a sample. If you use a workstation or
a server (from the java client side) you have to install the driver:
SQLClientAccess (which can be free downloaded on the Progress webside -> Deployement Componets)

for a AppSerrver - State-free use:
myConn.setSessionModel(1);
and for Staless myConn.setSessionModel(0);
If I well remember :)



javac -classpath .:$DLC/java/o4glrt.jar sampleClient.java;
java -classpath .:$DLC/java/o4glrt.jar sampleClient;

import com.progress.open4gl.javaproxy.*;
import com.progress.open4gl.Parameter;

public class sampleClient {
private static final java.lang.String tName = new String( "KM_client" );
public static void nonPersistentProcedure() {
try {
// Connect to the AppServer
/*
Connection syntax is:
via NameServer:
[[AppServer:][//name-server-host][:name-server-port]/[service-name]]
DirectConnect:
[[AppServerDC:][//AppServer-host][:AppServer-port]
*/
//String appServerURL = "AppServer://rs:5163/asws";
String appServerURL = "AppServerDC://rs:3091";
Connection myConn = new Connection(appServerURL,"","","");
//change the operating mode to session free
myConn.setSessionModel(1);
OpenAppObject dynAO = new OpenAppObject(myConn, "asws");
// Create the parameters
Integer iCustNum = new Integer(9);
String cCustomerName;
// Create a place for RETURN-VALUE
String retVal;
// Create the ParamArray
ParamArray parms = new ParamArray(2);
// Set up input parameters
parms.addInteger(0, iCustNum, ParamArrayMode.INPUT);
// Set up Out parameters - notice the value is null
parms.addCharacter(1, null, ParamArrayMode.OUTPUT);
// Run the procedure
dynAO.runProc("getCustomerName.p", parms);
// Get output parameters - Returned as Object, so must cast
cCustomerName = (String) parms.getOutputParameter(1);
// Get RETURN-VALUE - Will return null for getCustomerName() procedure
retVal = (String)(parms.getProcReturnString());
dynAO._release();
System.out.println("Customer Name = " + cCustomerName);
System.out.println("RETURN VALUE = " + retVal);
} // try to catch all unexpected exceptions
catch ( Exception e ) {
System.out.println("Exception in sample()");
System.out.println("Exception Message: " + e.getMessage());
e.printStackTrace();
}
} //nonPersistentProcedure

public static void main(String[] args) {

sampleClient a = new sampleClient();
a.nonPersistentProcedure();

} //main

} // class
 
Back
Top