Cognos SDK Guide by BI Centre can be purchased from PayPal.

You will have your own functional Cognos 8 SDK web solution that has been tailored to be scalable and flexible in order to adapt to your unique business requirements and solution architecture.


Friday, January 11, 2008

Exception Handler Class -- Exhandler.cs

ExHandler.cs is used to handle SOAP Exceptions that may be encountered when making Cognos service requests.  The ExHandler.cs class allows you to display a meaningful error message to the end user.  It captures the severity, error code, message and details of the exception that has been encountered.  These values are appended and returned as a string.

 

This is example code to capture the Exception’s severity.

 

/// Return the exception severity. ///

public string Severity{

      get{

            XmlNode severityNode = exSoap.Detail.SelectSingleNode( "//severity");

                  if (severityNode != null)

                  {

                        return severityNode.InnerText;

                  }

                       

return "";

                 

}

}

 

 

 

Your web solution should have all of it’s TRY-CATCH statements updated in order to reference the functionality ExHandler.cs class file.  You would simply have to instantiate the object in your updated Catch statements.

 

ExHandler exCognos = new ExHandler(exSoap);

 

 

Here is a more detailed example showing the updated Catch statement and appending a string object with the full exception message.

 

try

                  {

                        _cmService = new contentManagerService1();

                        _rptService = new reportService1();

 

                        _dispC8 = ConfigurationSettings.AppSettings["CognosDispatcher"];

                        _NmSpace = ConfigurationSettings.AppSettings["CNmspace"];

                        _Pwd = ConfigurationSettings.AppSettings["CTSpwd"];

                        _Uid = ConfigurationSettings.AppSettings["CTSuid"];

                        _CSTypePkg = ConfigurationSettings.AppSettings["CSTypePkg"];

                        _CSTypeRpt = ConfigurationSettings.AppSettings["CSTypeRpt"];

 

                        _cmService.Url = _dispC8;

                        _rptService.Url = _dispC8;

 

                        _cogSDK = new CognosSDK();

 

                        _cogSDK.CognosLogon(_cmService,_NmSpace,_Uid, _Pwd);

                        _rptService.biBusHeaderValue = _cmService.biBusHeaderValue;

                  }

 

                  catch (SoapException exSoap)

                  {

                        ExHandler exCognos = new ExHandler(exSoap);

                        _ErrMsg = exCognos.Details + " :-: " + exCognos.Message +  " :-: " + exCognos.Severity +  " :-: " + exCognos.ErrorCode;

                  }

                  catch (Exception ex)

                  {

                        _ErrMsg = ex.Message.ToString();

                  }