Cognos API Connection

来源:互联网 发布:2016知乎年度吐槽精选3 编辑:程序博客网 时间:2024/06/05 11:13

         Cognos Connection, 通过 Cogons API 访问Cogons 已经安装好的平台,获取已经创建好的Report,修改此report,或者运行此report获取结果等。。。

分析Connection. 简单代码如下:

package test;import java.net.URL;import javax.xml.namespace.QName;import org.apache.axis.client.Stub;import org.apache.axis.message.SOAPHeaderElement;import com.cognos.developer.schemas.bibus._3.BaseClass;import com.cognos.developer.schemas.bibus._3.BiBusHeader;import com.cognos.developer.schemas.bibus._3.ContentManagerService_PortType;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.Report;import com.cognos.developer.schemas.bibus._3.SearchPathMultipleObject;import com.cognos.developer.schemas.bibus._3.Sort;import com.cognos.developer.schemas.bibus._3.XmlEncodedXML;public class CognosConnectionUtil{    private ContentManagerService_PortType cmService = null;    public static void main(String[] a) throws Exception    {        //1. instantiate the class        CognosConnectionUtil mainClass = new CognosConnectionUtil();         // Step 2: Logon to Cognos        mainClass.logonToCognos();        // Step 3: Execute tasks        mainClass.executeTasks();        // Step 4: Logoff from Cognos        mainClass.logoffFromCognos();    }    // Step 2: Logon to Cognos    private void logonToCognos() throws Exception    {        String dispatcherURL = "http://xxxxxxxxxxxxxxxxxx/p2pd/servlet/dispatch";        String nameSpaceID = "XXXXX";        String userName = "XXXX";        String password = "XXXXX";        ContentManagerService_ServiceLocator cmServiceLocator = new ContentManagerService_ServiceLocator();        URL url = new URL(dispatcherURL);        cmService = cmServiceLocator.getcontentManagerService(url);        StringBuffer credentialXML = new StringBuffer();        credentialXML.append("<credential>");        credentialXML.append("<namespace>").append(nameSpaceID).append("</namespace>");        credentialXML.append("<username>").append(userName).append("</username>");        credentialXML.append("<password>").append(password).append("</password>");        credentialXML.append("</credential>");        String encodedCredentials = credentialXML.toString();        XmlEncodedXML xmlCredentials = new XmlEncodedXML();        xmlCredentials.set_value(encodedCredentials);        cmService.logon(xmlCredentials, null);        SOAPHeaderElement temp = ((Stub) cmService).getResponseHeader("http://developer.cognos.com/schemas/bibus/3/", "biBusHeader");        System.out.println(temp.toString());        BiBusHeader CMbibus = (BiBusHeader) temp.getValueAsType(new QName("http://developer.cognos.com/schemas/bibus/3/", "biBusHeader"));        ((Stub) cmService).setHeader("http://developer.cognos.com/schemas/bibus/3/", "biBusHeader", CMbibus);    }    // Step 3: Execute tasks    private String executeTasks()    {        PropEnum props[] = Util.getAllPropEnum();        BaseClass bc[] = null;        String searchPath = "/content/folder[@name='Test']/report[@name='test']";        try        {            SearchPathMultipleObject spMulti = new SearchPathMultipleObject(searchPath);            bc = cmService.query(spMulti, props, new Sort[] {}, new QueryOptions());        }        catch (Exception e)        {            e.printStackTrace();        }        System.out.println("PACKAGES:\n");        if (bc != null)        {            for (int i = 0; i < bc.length; i++)            {                Report report = (Report) bc[i];                System.out.println(report.getDefaultName());            }        }        return searchPath;    }    // Step 4: Logoff from Cognos    private void logoffFromCognos()    {        try        {            cmService.logoff();        }        catch (Exception ex)        {            ex.printStackTrace();        }    }}


0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 求你们了,让朕当个昏君吧 凌队的千面保镖超A的 我不只是动作巨星 穿越三国:这个阿斗不用扶 绑定百亿物资系统后暴富古代了 遮天之凡体至尊 穿越诸天神话 重生79之我在美国开银行 首次穿越撞上氢弹是否搞错了什么 港综世界的警察 满朝奸臣,你让朕怎么当千古一帝 我的火种战舰 我在魔王城伪装怪物 女配在年代文里做万人迷 九品仙路 护林日常:开局拯救大熊猫 穿越兽世:种田驭夫乐悠悠 不灭战神 我在宝可梦世界开餐厅 爸爸,我是来当你同学的 这个主角明明很强却异常谨慎 四合院:我的穿越为啥这么陋 甩了线上男友后我被亲哭了 人在南天坐看万古 为了成为英灵我只好在历史里搞事 我成了游戏里的反派之王 离婚后,前夫每天都想上位 霍格沃茨的风与鹰翼 攻略暴君后,我抱错大腿了 我的精灵模拟器 金鸾喜嫁 人在美漫,开局枪斗术 大国科技从手机开始 人住超神,渣在诸天 斗罗之王者吕布降临 从白蛇开始诸天改命 诸天之天外降临者 屠龙之前就读过龙族的路明非 足球盛宴,从收购欧洲俱乐部开始 在漫威驱魔的魔鬼神父 柯南之我的老姐毛利兰