关于Cognos sdk开发的问题
0
我这边的问题是,系统需要在其他服务器访问Cognos报表,但是访问的时候需要输入账号密码。早在访问系统之前就已经做了一次登录,(两个服务器账号密码通用)故我现在是想在我第一次登录的时候 成功登录之后就拿这个账号密码去调用Cognos的sdk登录Cognos,在下次我想要访问报表的时候 就不需要再次输入账号密码了。我这边也参照了文档和demo,代码可以正常运行,但是实际上感觉并没有什么用,我在程序里面登录了之后 ,在打开浏览器的新窗口,手动输入报表地址,任然要求我再次输入账号密码。下面是我的代码:
try
{
System.Text.StringBuilder credentialXML = new System.Text.StringBuilder("<credential>");
credentialXML.AppendFormat("<namespace>{0}</namespace>", userNamespace);
credentialXML.AppendFormat("<username>{0}</username>", userName);
credentialXML.AppendFormat("<password>{0}</password>", userPassword);
credentialXML.Append("</credential>");
//加密 credentials
string encodedCredentials = credentialXML.ToString();
xmlEncodedXML xmlEncodedCredentials = new xmlEncodedXML();
xmlEncodedCredentials.Value = encodedCredentials;
searchPathSingleObject[] emptyRoleSearchPathList = new searchPathSingleObject[0];
string aa = cBIUrl;
cBICMS = new contentManagerService1();
cBICMS.Url = aa;
cBICMS.logon(xmlEncodedCredentials, null);
// sn_dg_prm_sdk_method_contentManagerService_logon_end_0
//hang on to the user data locally for use elsewhere
setUserName(userName);
setUserPassword(userPassword);
setNamespace(userNamespace);
isLoggedOn = true;
}
catch (SoapException ex)
{
isLoggedOn = false;
// SamplesException.ShowExceptionMessage( ex, guiMode, "Unable To Logon" );
}
我这边测试是在本地做的测试,不知道会不会是和环境有关,还有,会不会不是我这种解决方式?
try
{
System.Text.StringBuilder credentialXML = new System.Text.StringBuilder("<credential>");
credentialXML.AppendFormat("<namespace>{0}</namespace>", userNamespace);
credentialXML.AppendFormat("<username>{0}</username>", userName);
credentialXML.AppendFormat("<password>{0}</password>", userPassword);
credentialXML.Append("</credential>");
//加密 credentials
string encodedCredentials = credentialXML.ToString();
xmlEncodedXML xmlEncodedCredentials = new xmlEncodedXML();
xmlEncodedCredentials.Value = encodedCredentials;
searchPathSingleObject[] emptyRoleSearchPathList = new searchPathSingleObject[0];
string aa = cBIUrl;
cBICMS = new contentManagerService1();
cBICMS.Url = aa;
cBICMS.logon(xmlEncodedCredentials, null);
// sn_dg_prm_sdk_method_contentManagerService_logon_end_0
//hang on to the user data locally for use elsewhere
setUserName(userName);
setUserPassword(userPassword);
setNamespace(userNamespace);
isLoggedOn = true;
}
catch (SoapException ex)
{
isLoggedOn = false;
// SamplesException.ShowExceptionMessage( ex, guiMode, "Unable To Logon" );
}
我这边测试是在本地做的测试,不知道会不会是和环境有关,还有,会不会不是我这种解决方式?
没有找到相关结果
重要提示:提问者不能发表回复,可以通过评论与回答者沟通,沟通后可以通过编辑功能完善问题描述,以便后续其他人能够更容易理解问题.
1 个回复
H_Elsker - 修地球工程师,cognos,Hadoop 2015-10-29 回答
赞同来自: basiph
2、还有一个办法,就是在你cognos 地址后面写死用户名密码,这种方法只能一时忽悠住客户,考虑权限的时候,就不好过关了