Kbase P123116: How to return a user defined string to a .NET client from the AppServer connection procedure
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  3/29/2007 |
|
Status: Unverified
GOAL:
How to return a user defined string to a .NET client from the AppServer connection procedure
FACT(s) (Environment):
When you establish a connection to the AppServer with the .NET 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 RETURN string statement, then that string will be contained in the connection failure exception.
If the connection is successful, and the connection procedure has a RETURN string statement, you can access the string using the existing AppObject public property ProcReturnString. If the connect procedure does not return a value, then the ProcReturnString property will be null.
The following sample .NET Open Client code illustrates this functionality:
private void button1_Click(object sender, EventArgs e)
{
try
{
toolStripStatusLabel1.Text = "Connecting to the AppServer...";
string connectionStr = "";
connectionStr += "AppServer://localhost:5162/wservices02";
conn = new Connection(connectionStr, "", "", "");
conn.SessionModel = 0;
appObj = new WSTest(conn);
if (!string.IsNullOrEmpty(appObj.ProcReturnString))
{
MessageBox.Show(appObj.ProcReturnString);
}
toolStripStatusLabel1.Text = "Connected";
}
catch (Open4GLException ex)
{
// if there is a application defined return string, then display it
if (!string.IsNullOrEmpty(ex.ProcReturnString))
{
MessageBox.Show(ex.ProcReturnString);
//MessageBox.Show(this, ex.Message);
toolStripStatusLabel1.Text = "Connection failed";
}
&.nbsp; else
{
// display Progress defined error message
MessageBox.Show(ex.ToString());
toolStripStatusLabel1.Text = "Connection failed";
}
}
finally
{
if (appObj != null)
{
appObj.Dispose();
}
}
}
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.
.