Returning a user defined string to the client from the AppServer connection procedure
When you establish a connection to the AppServer with the Java Open Client, you instantiate an AppObject using one of the four constructors provided by ProxyGen. If the connection to the AppServer fails, the AppObject constructor throws a standard exception. This exception can also contain a user defined string, if you have set up your AppServer to do so.
The Connection object communicates with a remote ABL procedure stored on the AppServer known as the connection procedure. If that procedure contains the ABL RETURNstring statement, then that string will be contained in the connection failure exception.
If the connection is successful, and the connection procedure has an ABL RETURNstring statement, you can access the string using the AppObject method _getProcReturnString(). If the connect procedure does not return a value, then the _getProcReturnString() method returns null.
The following sample Java Open Client code illustrates this functionality:
try
{
//Create Customer AppObject to connect
Customer appObj = new Customer(ConnectObj);
System.out.println((String) appObj._getProcReturnString());
}
catch (com.progress.open4gl.Open4GLException ex)
{
// if there is a application defined return string, then display it
if ((String)(ex._getProcReturnString()) != null)
{
System.out.println((String)(ex._getProcReturnString());
}
else
{
// display Progress defined error message
System.out.println(ex.toString());
// or display new generic message
System.out.println("Connection failed");
}
}
finally
{ if (appObj != null)
{
appObj._release();
}
}
If the connection is successful and the connect procedure returns a string, then the string value is displayed by the first message box. If the connect procedure failed and returns a string, then the string value is displayed by the second message box.
Note: This feature is only available to AppServer applications using the managed-session model, since it is this type of application that uses a connection procedure.