• Cognos API Connection


    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:
    ");
            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();
            }
        }
    }
    



  • 相关阅读:
    macOS下查看端口是否被占用命令
    macOS下安装tomcat服务器
    unittest 知识问答题-也许面试会有用-欢迎补充
    python.unittest中常用断言方法
    如何在命令行terminal中运行pycharm项目
    如何保证 软件测试覆盖率
    如何衡量 测试覆盖率
    软件测试全流程 总结
    接口测试对传统测试模型的改进
    关于http/https协议
  • 原文地址:https://www.cnblogs.com/xue88ming/p/7182995.html
Copyright © 2020-2023  润新知