Cognos SDK初体验一

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
public class SimpleTest1 { private static String dispatcherURL =
"http://COGDEV:9300/p2pd/servlet/dispatch"; private ContentManagerService_PortType cmService = null;
三、步骤
0、准备工作:安装 Cognos BI Server,安装 Cognos SDK
1、 创建 Java 项目,设置依赖包-拷贝所有在 cognos\c10_64\sdk\java\lib 下的 jar 包
注:依赖包位于 SDK 已安装路径 C:\IBM\、创建一个简单的测试程序
Illustration 3: IBM Cognos Configuration showing the “Dispatcher URI for external applications” field
Once connected to an IBM Cognos BI Dispatcher, the IBM Cognos Software Development Kit application requests an IBM Cognos BI service. Unless the application is going to use the Anonymous credentials, the application must request the Content Manager service because that is the service that handles the logon/logoff processes.
Cognos SDK 初体验一
-- by Bill, 2014
一、场景: 在目前允许匿名登录的 Cognos 10.2.1 BI 服务器上测试 SDK
二、SDK 测试程序部署
SDK 测试应用程序作为 stand alone Java 应用程序部署,作为客户端,利用 Cognos SDK 提供的 JAR 包,访问远端独立的 BI 服务器。Cognos SDK 提供的 JAR 包内部 通过 Web Service 方式访问 BI 服务器。
Method name : connectToCognos The IBM Cognos Software Development Kit program must first connect to an IBM Cognos BI Dispatcher using the URL of the IBM Cognos BI server. This URL is defined in IBM Cognos Configuration and is the value of the “Dispatcher URI for external applications” field. The URL has the form http://host.domain:port/p2pd/servlet/dispatch.
public static void main(String[] args) { SimpleTest1 test = new SimpleTest1(); // Step 1: Connect to the Cognos services test.connectToCognos(dispatcherURL);
1
import com.cognos.developer.schemas.bibus._3.ContentManagerService_ServiceLocator; import com.cognos.developer.schemas.bibus._3.PropEnum; import com.cognos.developer.schemas.bibus._3.QueryOptions; import com.cognos.developer.schemas.bibus._3.SearchPathMultipleObject; import com.cognos.developer.schemas.bibus._3.Sort;
// Step 2: Logon to Cognos //mainClass.logonToCognos(nameSpaceID, userName, password);
// Step 3: Execute tasks test.executeTasks();
// Step 4: Logoff from Cognos //mainClass.logoffFromCognos(); } // Step 1: Connect to the Cognos services private void connectToCognos(String dispatcherURL) { ContentManagerService_ServiceLocator cmServiceLocator = new ContentManagerService_ServiceLocator();
package test; import .URL; import com.cognos.developer.schemas.bibus._3.BaseClass; import com.cognos.developer.schemas.bibus._3.ContentManagerService_PortType;
Step 2: Logon to the IBM Cognos BI server
Method name : logonToCognos
4
Logon is done through the Content Manager service. IBM Cognos BI supports both authenticated and anonymous user access. In this step, if the anonymous access is disabled, then the SDK application must logon using a namespace ID, a user name and its associated password. The namespace ID is the value of the Namespace ID field in IBM Cognos Configuration.
try { URL url = new URL(dispatcherURL);
cmService = cmServiceLocator.getcontentManagerService(url); } catch (Exception e) {
e.printStackTrace(); } }
// Step 3: Execute tasks private void executeTasks() {
SearchPathMultipleObject( searchPath);
bc = cmService.query(spMulti, props, new Sort[] {}, new QueryOptions());
} catch (Exception e) { e.printStackTrace();
A typical IBM Cognos Software Development Kit program has four primary sections. 1. Connect to the IBM Cognos BI service(s) 2. Logon to IBM Cognos BI 3. Execute tasks 4. Logoff from IBM Cognos BI
PropEnum props[] = new PropEnum[] { PropEnum.searchPath, PropEnum.defaultName };
BaseClass bc[] = null; String searchPath = "/content//package";
try { SearchPathMultipleObject spMulti = new
This document contains a sample SDK application written in Java and contains methods that correspond to these primary sections.
Step 1: Connect to the IBM Cognos BI server
2
+"-"
} }
return; }
System.out.println("PACKAGES:\n"); if (bc != null) {
for (int i = 0; i < bc.length; i++) { System.out.println(bc[i].getDefaultName().getValue()
} }
+ bc[i].getSearchPath().getValue());
3、试运行
log4j:WARN No appenders could be found for logger (org.apache.axis.i18n.ProjectResourceBundle). log4j:WARN Please initialize the log4j system properly. PACKAGES:
GO 数据仓库 (分析) - /content/folder[@name='示样']/folder[@name='模型 ']/package[@name='GO 数据仓库 (分析)'] GO 数据仓库 (查询) - /content/folder[@name='示样']/folder[@name='模型 ']/package[@name='GO 数据仓库 (查询)'] GO 销售 (分析) - /content/folder[@name='示样']/folder[@name='模型 ']/package[@name='GO 销售 (分析)'] GO 销售 (查询) - /content/folder[@name='示样']/folder[@name='模型 ']/package[@name='GO 销售 (查询)'] GO 数据仓库 (分析) - /content/folder[@name='示样_DQ']/folder[@name='模型 ']/package[@name='GO 数据仓库 (分析)'] GO 数据仓库 (查询) - /content/folder[@name='示样_DQ']/folder[@name='模型 ']/package[@name='GO 数据仓库 (查询)'] GO 销售 (查询) - /content/folder[@name='示样_DQ']/folder[@name='模型 ']/package[@name='GO 销售 (查询)'] GO 销售 (分析) - /content/folder[@name='示样_DQ']/folder[@name='模型 ']/package[@name='GO 销售 (分析)']
四、接下来 配置 Cognos 安全,禁用匿名登录,参考以下文档,继续 SDK 开发
参考 /developerworks/data/library/cognos/development/how_to/page565. html
3
下面是部分摘录:
The Structure of an IBM Cognos Software Development Kit Program
相关文档
最新文档