Writing a program that logs in to BIRT iHub System
A login operation authenticates a user in BIRT iHub System . A login operation involves the following actions:
*An IDAPI application sends a Login request to BIRT iHub System .
*BIRT iHub System sends a Login response to the IDAPI application.
A Login action receives a LoginResponse message from BIRT iHub System . When a Login action succeeds, the LoginResponse message contains an AuthId, which is an encrypted, authenticated token. When a Login action fails, BIRT iHub System sends a LoginResponse message containing an error code and a description of the error.
The authentication ID in the LoginResponse message remains valid for the current session. Any subsequent request that the application sends to an Encyclopedia volume must include the authentication ID in the message. The following sections describe the SOAP messages, classes, and program interactions necessary to implement a successful login operation.
The following application derives from the code in the BIRT iHub Integration Technology example applications for the MS .NET Client. AcLogin class logs in to the Encyclopedia volume to authenticate the user. If the login succeeds, the application prints a success message. If the login fails, the application prints a usage message. In AcLogin class, Main function performs the following operations:
*Specifies Actuate namespace and calls Usage function, which analyzes the command line arguments as shown in the following code:
using System;
using System.Web.Services.Protocols;
using Server_Proxy.localhost;
namespace Actuate
{
class AcLogin
{
[STAThread]
static void Main(string[ ] args)
{
string l_url;
string l_userName;
string l_password;
string l_volumename;
if ( Usage(args, out l_url, out l_userName,
out l_volumename, out l_password) == 0) return;
The following list describes the options that can be specified as command line arguments:
*serverURL
-h specifies the SOAP endpoint. The default value is http://localhost:8000.
*username
-u specifies the user name. The default value is Administrator.
*password
-p specifies the password. The default value is "".
*volumename
-v specifies the target volume name. Actuate Release 11 requires a volume name in the SOAP header. For earlier releases, this specification is optional.
*printUsage
-? prints the usage statement. The default value is the following string:
Usage: Login -h http://localhost:8000 -u username -p password -? help
*Creates an instance of the server proxy and constructs the SOAP header:
ActuateAPI l_proxy = new ActuateAPI( );
l_proxy.HeaderValue = new Header( );
l_proxy.Url = l_url;
AcLogin uses the following classes defined in References.cs to perform these operations:
*ActuateAPI class is a subclasses of System.Web.Services.Protocols.SoapHttpClientProtocol that specifies the protocol for .NET to use at run time and defines the proxies used to make web service requests.
*Header class is a subclass of System.Web.Services.Protocols.SoapHeader that defines the following Actuate SOAP header extensions:
*AuthId is a system-generated, encrypted string returned by BIRT iHub in a Login response. All requests, except a Login request, must have a valid AuthId in the SOAP header.
*Locale specifies the language, date, time, currency, and other conventions for BIRT iHub to use when returning data to a client.
*TargetVolume is an optional element that indicates the Encyclopedia volume that receives the request.
*ConnectionHandle supports keeping a connection open to view a persistent report. If ConnectionHandle is present in the SOAP header, the system routes subsequent viewing requests to the same View service that returned the ConnectionHandle.
*DelayFlush tells BIRT iHub to write updates to the disk when the value is False.
*Instantiates the Login object and prepares the login parameters
Server_Proxy.localhost.Login l_req =
new Server_Proxy.localhost.Login( );
l_req.Password = l_password;
l_req.User = l_userName;
l_req.Domain = l_volumename;
l_req.UserSetting = true;
l_req.UserSettingSpecified = true;
*Sends the Login request, handling any exceptions by writing a usage statement to the console
LoginResponse l_res;
try
{
l_res = l_proxy.login(l_req);
}
catch(SoapException e)
{
Console.WriteLine("Please try again.\n
Usage: Login -h http://localhost:8000
-u username -p password -v volumename -? help \n"); PrintExceptionDetails((SoapException) e);
return;
}
*Processes a successful Login response by writing a success message to the console and storing AuthId as a SOAP header value for use in the next request
Console.WriteLine("Congratulations! You have successfully
logged into BIRT iHub System as "+l_userName);
// Store the authentication id
l_proxy.HeaderValue.AuthId = l_res.AuthId;
}
AcLogin uses the Actuate Information Delivery API classes in References.cs, generated from the Actuate WSDL document. References.cs provides the following code definitions:
*Declares the proxy namespace, XML serialization, and web services protocols for the system
namespace Server_Proxy.localhost {
using System.Diagnostics;
using System.Xml.Serialization;
using System;
using System.Web.Services.Protocols;
using System.ComponentModel;
using System.Web.Services;
*Defines the ActuateAPI class, which specifies the bindings for the SOAP HTTP client protocol, extended Actuate SOAP header values, and proxy calls
[System.Web.Services.WebServiceBindingAttribute(
Name="ActuateSoapBinding",
Namespace="http://schemas.actuate.com/actuate11/wsdl")]
public class ActuateAPI
: System.Web.Services.Protocols.SoapHttpClientProtocol {
public Header HeaderValue;
public ActuateAPI( ) {
this.Url = "http://ENL2509:8000";
}
/// <remarks/>
[System.Web.Services.Protocols.SoapHeaderAttribute
("HeaderValue")]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute(
"", Use=System.Web.Services.Description.SoapBindingUse
.Literal,ParameterStyle=
System.Web.Services.Protocols.SoapParameterStyle.Bare)]
[return:
System.Xml.Serialization.XmlElementAttribute(
"LoginResponse",
Namespace="http://schemas.actuate.com/actuate11")]
public LoginResponse
login([System.Xml.Serialization.XmlElementAttribute
(Namespace="http://schemas.actuate.com/actuate11")] Login
Login) {
object[ ] results = this.Invoke("login", new object[ ] {
Login});
return ((LoginResponse)(results[0]));
}