/** * Create an instance of the Session with a connection to the specified * server. * * Add implementations of the ExceptionHandler, PartialErrorListener, * ChangeListener, and DeleteListeners. * * @param host Address of the host to connect to, http://serverName:port/tc */ public Session(String host) { // Create an instance of the CredentialManager, this is used // by the SOA Framework to get the user's credentials when // challanged by the server (sesioin timeout on the web tier). credentialManager = new AppXCredentialManager(); string proto = null; string envNameTccs = null; if (host.StartsWith("http")) { proto = SoaConstants.HTTP; } else if (host.StartsWith("tccs")) { proto = SoaConstants.TCCS; int envNameStart = host.IndexOf('/') + 2; envNameTccs = host.Substring(envNameStart, host.Length - envNameStart); } // Create the Connection object, no contact is made with the server // until a service request is made connection = new Connection(host, new System.Net.CookieCollection(), credentialManager, SoaConstants.REST, proto, false); if (proto == SoaConstants.TCCS) { connection.SetOption(Connection.TCCS_ENV_NAME, envNameTccs); } // Add an ExceptionHandler to the Connection, this will handle any // InternalServerException, communication errors, xml marshalling errors // .etc connection.ExceptionHandler = new AppXExceptionHandler(); // While the above ExceptionHandler is required, all of the following // Listeners are optional. Client application can add as many or as few Listeners // of each type that they want. // Add a Partial Error Listener, this will be notified when ever a // a service returns partial errors. connection.ModelManager.AddPartialErrorListener(new AppXPartialErrorListener()); // Add a Change and Delete Listener, this will be notified when ever a // a service returns model objects that have been updated or deleted. connection.ModelManager.AddModelEventListener(new AppXModelEventListener()); // Add a Request Listener, this will be notified before and after each // service request is sent to the server. Connection.AddRequestListener(new AppXRequestListener()); }