CognosSDK Java登陆到Cognos
来源:互联网 发布:seo发外链 编辑:程序博客网 时间:2024/05/17 09:00
package com.resoft.navigate.util;
//Cognos Sdk调用包
//axisCrnpClient.jar
import javax.xml.rpc.ServiceException;import org.apache.axis.AxisFault;import org.apache.axis.client.Stub;import com.cognos.developer.schemas.bibus._3.*;public class CognosLoginTest{private ContentManagerService_Port cmService = null;private ReportService_Port reportService = null;// connect to Cognos8 servicespublic void connectToReportServer(String endPoint){ try{ ContentManagerService_ServiceLocator cmServiceLocator = new ContentManagerService_ServiceLocator(); ReportService_ServiceLocator rsServiceLocator = new ReportService_ServiceLocator(); cmService = cmServiceLocator.getcontentManagerService(new java.net.URL(endPoint)); reportService = rsServiceLocator.getreportService(new java.net.URL(endPoint)); }catch (ServiceException ex){ System.out.println("Caught a ServiceException: " + ex.getMessage()); ex.printStackTrace(); }catch (Exception ex){ System.out.println("Cognos 8 server URL was: " + endPoint); }}// logon to Cognos 8public String quickLogon(String namespace, String uid, String pwd){ StringBuffer credentialXML = new StringBuffer(); credentialXML.append("<credential>"); credentialXML.append("<namespace>").append(namespace).append("</namespace>"); credentialXML.append("<username>").append(uid).append("</username>"); credentialXML.append("<password>").append(pwd).append("</password>"); credentialXML.append("</credential>"); String encodedCredentials = credentialXML.toString(); XmlEncodedXML xmlCredentials = new XmlEncodedXML(); xmlCredentials.setValue(encodedCredentials); try{ cmService.logon(xmlCredentials, null); BiBusHeader CMbibus = (BiBusHeader) ((Stub) cmService).getHeaderObject("", "biBusHeader"); ((Stub) reportService).setHeader("", "biBusHeader", CMbibus); System.out.println("login 0k"); }catch (Exception e){ e.printStackTrace(); } System.out.println("Logon successful as " + uid); return ("Logon successful as " + uid);}public static void main(String[] args){ String namespaceID = "dbAuth"; String userID = "dssadmin"; String password = "123"; String endPoint = "http://10.0.3.199:81/cognos8/cgi-bin/cognos.cgi"; CognosLoginTest gc = new CognosLoginTest(); gc.connectToReportServer(endPoint); gc.quickLogon(namespaceID, userID, password); System.out.println("OK"); }}
上面的代码在tommcat/websphere都没问题,但是在一客户使用weblogic却发现问题,在执行 cmService.logon(xmlCredentials, null);代码时就抛出异常,查阅相关资料发现,weblogic在解释XML格式时有自己的方法,原因如下:
1、weblogic8自带的xml解析器不能解析GBK编码的,如果要让weblogic能够解析GBK编码,那么需要为weblogic8配置额外的xml解析器;
2、 一般使用apache的xml解析器,也就是Xerces.jar和Xalan.jar;
需要在操作系统的当前用户下设定classpath指定上面的xml解析器, 在weblogic的控制台执行如下操作解决:
1、在控制台的导航树中找到Services->XML这一节点,点击该节点创建一个XML Registries,主要是填写一些类的全名,这些类在上面的xml解析器中,即上面的jar包中,配置如下
Document Builder Factory:org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
SAX Parser Factory:org.apache.xerces.jaxp.SAXParserFactoryImpl
Transformer Factory:org.apache.xalan.processor.TransformerFactoryImpl
2、点击apply
3、如果在myeclipse中启动weblogic8,那么还需要做如下配置,启动后的weblogic8才能支持GBK,进入到window->preferences->MyEclipse->Application Server->weblogic8->paths将Xerces.jar和Xalan.jar的路径加入到prepend to classpath中
Cognos 集成jar
以下jar包的api:
axis.jar
axisCrnpClient.jar
axisCognosClient.jar
commons-discovery.jar
commons-logging.jar
jaxrpc.jar
saaj.jar
wsdl4j.jar
xercesImpl.jar
xml-apis.jar
dom4j.jar
xalan.jar
- CognosSDK Java登陆到Cognos
- Cognos ReportNet 与WEB应用同时登陆
- cognos 用户权限更新到cube
- CognosSDK 查询Content Store
- Cognos
- Cognos
- Cognos
- Cognos
- Cognos
- Cognos
- cognos
- cognos
- cognos
- cognos
- cognos
- Cognos报表参数值保存到Excel
- 退回到登陆页面
- 无法登陆到域
- Linux移植之驱动编译出现的问题
- 如何移植library到Android(二)
- linux内核镜像格式
- 新的开始
- 整数<=>指针
- CognosSDK Java登陆到Cognos
- 如何移植library到android
- 网上整理的google面试题
- mainfest机制
- java 中的enum(枚举)
- win7 64位 安装pl/sql客户端不能放在非常规路径
- 习题4
- Android IPC 通讯机制源码分析 二
- batis 错误 Mapped Statements collection does not contain value for