Purchase your Section 508 Compliance Support guide now!

Purchase your Section 508 Compliance Support guide now!

Cognos SDK -- C# logon example

Hello, as promised here is our first example of using the Cognos SDK with C# (c-sharp).  It is a basic logon method using hard coded user credentials.

 

You will soon find that most examples that Cognos provides are geared toward Java developers, so please feel free to contact me if you would like to discuss any .NET based examples in C# or VB.NET.

 

Logon.cs

 

private void btnSDKLogon_Click(object sender, System.EventArgs e)

              {

                     contentManagerService1 cm = new contentManagerService1();

                     cm.Url = "http://localhost:9330/p2pd/servlet/dispatch";

 

                     string defaultUserName = "Administrator";

                     string defaultPassword = "Password1";

                     string defaultNamespace = "DLDAP";

                     string cam_passsport = null;

 

                     try

                     {

                           System.Text.StringBuilder credentialXML = new System.Text.StringBuilder("<credential>" );

                           credentialXML.AppendFormat( "<namespace>{0}</namespace>", defaultNamespace );

                           credentialXML.AppendFormat( "<username>{0}</username>", defaultUserName );

                           credentialXML.AppendFormat( "<password>{0}</password>", defaultPassword );

                           credentialXML.Append( "</credential>" );

 

                           string encodedCredentials = credentialXML.ToString ();

                           xmlEncodedXML xmlEncodedCredentials = new xmlEncodedXML();

                           xmlEncodedCredentials.Value = encodedCredentials;

                           searchPathSingleObject[] emptyRoleSearchPathList = new searchPathSingleObject[0];

                           cm.logon(xmlEncodedCredentials, null);     

            

                           cam_passsport = cm.biBusHeaderValue.CAM.CAMPassport.id;

                          

                     }

                     catch( Exception ex )

                     {

                            Console.Write (ex.Message);

                     }

                     Console.Write (cam_passsport);

                     MessageBox.Show("cam_passport: " + cam_passsport);

              }