步骤1:

1、根据idl生成客户端代理(stub)和服务器框架(skeleton)

idl来源《OptiX iManager T2000 V200R007C03 Northbound CORBA Interface Reference Guide》

执行下面的命令来生成客户端代理(stub)和服务器框架(skeleton):

idlj -f all myIDL.idl

-f参数用来指定生成的内容,all包括客户端的本地代理和服务器框架。如果不加-f all参数的话,不会生成POA那个类。

"%JAVA_HOME%"\bin\idlj.exe -f all CosEventChannelAdmin.idl

"%JAVA_HOME%"\bin\idlj.exe -f all CosEventComm.idl

"%JAVA_HOME%"\bin\idlj.exe -f all CosNaming.idl

"%JAVA_HOME%"\bin\idlj.exe -f all CosNotification.idl

"%JAVA_HOME%"\bin\idlj.exe -f all CosNotifyChannelAdmin.idl

"%JAVA_HOME%"\bin\idlj.exe -f all CosNotifyComm.idl

"%JAVA_HOME%"\bin\idlj.exe -f all CosNotifyFilter.idl

"%JAVA_HOME%"\bin\idlj.exe -f all CosTrading.idl

"%JAVA_HOME%"\bin\idlj.exe -f all orb.idl

"%JAVA_HOME%"\bin\idlj.exe -f all CircuitCutMgr.idl

"%JAVA_HOME%"\bin\idlj.exe -f all common.idl

"%JAVA_HOME%"\bin\idlj.exe -f all CosEventChannelAdmin.idl

"%JAVA_HOME%"\bin\idlj.exe -f all CosEventComm.idl

"%JAVA_HOME%"\bin\idlj.exe -f all CosNaming.idl

"%JAVA_HOME%"\bin\idlj.exe -f all CosNotification.idl

"%JAVA_HOME%"\bin\idlj.exe -f all CosNotifyChannelAdmin.idl

"%JAVA_HOME%"\bin\idlj.exe -f all CosNotifyComm.idl

"%JAVA_HOME%"\bin\idlj.exe -f all CosNotifyFilter.idl

"%JAVA_HOME%"\bin\idlj.exe -f all CosTrading.idl

"%JAVA_HOME%"\bin\idlj.exe -f all emsMgr.idl

"%JAVA_HOME%"\bin\idlj.exe -f all emsSession.idl

"%JAVA_HOME%"\bin\idlj.exe -f all emsSessionFactory.idl

"%JAVA_HOME%"\bin\idlj.exe -f all encapsulationLayerLink.idl

"%JAVA_HOME%"\bin\idlj.exe -f all equipment.idl

"%JAVA_HOME%"\bin\idlj.exe -f all flowDomain.idl

"%JAVA_HOME%"\bin\idlj.exe -f all flowDomainFragment.idl

"%JAVA_HOME%"\bin\idlj.exe -f all globaldefs.idl

"%JAVA_HOME%"\bin\idlj.exe -f all guiCutThrough.idl

"%JAVA_HOME%"\bin\idlj.exe -f all HW_controlPlaneMgr.idl

"%JAVA_HOME%"\bin\idlj.exe -f all HW_mstpInventoryMgr.idl

"%JAVA_HOME%"\bin\idlj.exe -f all HW_mstpProtectionMgr.idl

"%JAVA_HOME%"\bin\idlj.exe -f all HW_mstpServiceMgr.idl

"%JAVA_HOME%"\bin\idlj.exe -f all HW_securityMgr.idl

"%JAVA_HOME%"\bin\idlj.exe -f all maintenanceOps.idl

"%JAVA_HOME%"\bin\idlj.exe -f all managedElement.idl

"%JAVA_HOME%"\bin\idlj.exe -f all managedElementManager.idl

"%JAVA_HOME%"\bin\idlj.exe -f all mtnmVersion.idl

"%JAVA_HOME%"\bin\idlj.exe -f all multiLayerSubnetwork.idl

"%JAVA_HOME%"\bin\idlj.exe -f all nmsSession.idl

"%JAVA_HOME%"\bin\idlj.exe -f all notifications.idl

"%JAVA_HOME%"\bin\idlj.exe -f all orb.idl

"%JAVA_HOME%"\bin\idlj.exe -f all performance.idl

"%JAVA_HOME%"\bin\idlj.exe -f all protection.idl

"%JAVA_HOME%"\bin\idlj.exe -f all session.idl

"%JAVA_HOME%"\bin\idlj.exe -f all subnetworkConnection.idl

"%JAVA_HOME%"\bin\idlj.exe -f all terminationPoint.idl

"%JAVA_HOME%"\bin\idlj.exe -f all topologicalLink.idl

"%JAVA_HOME%"\bin\idlj.exe -f all topologyManagementMgr.idl

"%JAVA_HOME%"\bin\idlj.exe -f all trafficDescriptor.idl

"%JAVA_HOME%"\bin\idlj.exe -f all transmissionParameters.idl

由于flowDomain.idl存在bug,因此需要修正。

搜索flowDomain.idl中的关键字flowDomain

找到

void getFlowDomain(

in globaldefs::NamingAttributes_T fdName,

out FlowDomain_T flowDomain)

raises(globaldefs::ProcessingFailureException);

再找

void getFDfromMFD(

in globaldefs::NamingAttributes_T mfdName,

out FlowDomain_T flowDomain )

raises(globaldefs::ProcessingFailureException);

将红体字的flowDomain修改为flowDomains

2、eclipse中新建java项目,将生成的java文件复制到src目录下

3、新建类test/NmsSessionImpl.java,父类为NmsSession_IPOA

4、新建类test/ClientTest.java,选中“public static void main(String args[])”

内容如下:

package test

import java.io.UnsupportedEncodingException;

import java.util.Date;

import managedElement.ManagedElementIterator_IHolder;

import managedElement.ManagedElementList_THolder;

import managedElement.ManagedElement_T;

import managedElementManager.ManagedElementMgr_I;

import managedElementManager.ManagedElementMgr_IHelper;

import multiLayerSubnetwork.SubnetworkIterator_IHolder;

import multiLayerSubnetwork.SubnetworkList_THolder;

import nmsSession.NmsSession_I;

import nmsSession.NmsSession_IPOA;

import notifications.EventIterator_IHolder;

import notifications.EventList_THolder;

import notifications.PerceivedSeverity_T;

import org.omg.CORBA.Any;

import org.omg.CORBA.IntHolder;

import org.omg.CORBA.ORB;

import org.omg.CORBA.Policy;

import org.omg.CORBA.SystemException;

import org.omg.PortableServer.POA;

import org.omg.PortableServer.POAHelper;

import org.omg.PortableServer.POAManagerPackage.AdapterInactive;

import org.omg.PortableServer.POAPackage.AdapterAlreadyExists;

import org.omg.PortableServer.POAPackage.InvalidPolicy;

import common.Common_IHolder;

import CosNaming.NameComponent;

import CosNaming.NamingContext;

import CosNaming.NamingContextHelper;

import CosNotification.Property;

import CosNotification.StructuredEvent;

import CosNotifyChannelAdmin.AdminLimitExceeded;

import CosNotifyChannelAdmin.AdminNotFound;

import CosNotifyChannelAdmin.ClientType;

import CosNotifyChannelAdmin.ConsumerAdmin;

import CosNotifyChannelAdmin.EventChannel;

import CosNotifyChannelAdmin.EventChannelHolder;

import CosNotifyChannelAdmin.ProxySupplier;

import CosNotifyChannelAdmin.StructuredProxyPushSupplier;

import CosNotifyChannelAdmin.StructuredProxyPushSupplierHelper;

import emsMgr.EMSMgr_I;

import emsMgr.EMSMgr_IHelper;

import emsMgr.EMS_T;

import emsMgr.EMS_THolder;

import emsSession.EmsSession_I;

import emsSession.EmsSession_IHolder;

import emsSession.EmsSession_IPackage.managerNames_THolder;

import emsSessionFactory.EmsSessionFactory_I;

import emsSessionFactory.EmsSessionFactory_IHelper;

import equipment.EquipmentInventoryMgr_I;

import globaldefs.NameAndStringValue_T;

import globaldefs.ProcessingFailureException;

public class ClientTest {

static ORB orb;

static EMSMgr_I emsMgr = null;

static EquipmentInventoryMgr_I equipmentInventoryMgr = null;

static EmsSession_I emsSession=null;

static EMS_THolder emsHolder = null;

static EMS_T ems = null;

static EventChannel notifChannel = null;

static EventChannelHolder chanHolder = new EventChannelHolder();

static ConsumerAdmin cadmin = null;

static IntHolder id = null;

static ProxySupplier baseSupplier = null;

static StructuredProxyPushSupplier structuredProxyPushSupplier = null;

static ManagedElementMgr_I managedElementMgr=null;

static StructuredPushConsumerImpl structProxyPushConsumer = null;

static POA rpoa = null;

static POA poa = null;

static Date start_time=new Date();

static Date end_time=new Date();

public static void testCorba() throws UnsupportedEncodingException{

//建立连接登录、建立消息通道

try {

String[] args = new String[2];

args[0] = "-ORBInitRef";

args[1] = "NameService=corbaloc::10.0.1.1:12001/NameService";

orb = org.omg.CORBA.ORB.init(args, null);

} catch (SystemException ex) {

System.out.println("初始化ORB对象异常!");

}

NamingContext namingContext = null;

org.omg.CORBA.Object objRef = null;

try {

objRef = orb.resolve_initial_references("NameService");

namingContext = NamingContextHelper.narrow(objRef);

System.out.println("获取取名字服务成功:"+namingContext);

}catch (org.omg.CORBA.ORBPackage.InvalidName ex) {

System.out.println("获取名字服务索引异常!");

ex.printStackTrace();

}

NameComponent[] path = new NameComponent[5];

path[0] = new NameComponent("TMF_MTNM", "Class");

path[1] = new NameComponent("HUAWEI", "Vendor");

path[2] = new NameComponent("Huawei/T2000", "EmsInstance");

path[3] = new NameComponent("2.0", "Version");

path[4] = new NameComponent("Huawei/T2000", "EmsSessionFactory_I");

EmsSessionFactory_I emsSessionFactory_I = null;

org.omg.CORBA.Object obj = null;

try{

obj = namingContext.resolve(path);

System.out.println("obj=>"+obj);

emsSessionFactory_I = EmsSessionFactory_IHelper.narrow(obj);

System.out.println("emsSessionFactory_I=>"+emsSessionFactory_I);

}catch(Exception e){

e.printStackTrace();

}

EmsSession_IHolder sessionHolder = new EmsSession_IHolder();

//Log In and Retrieve EmsSession

try {

NmsSession_IPOA pNmsSessionServant = new NmsSessionImpl();

NmsSession_I nmsSession = pNmsSessionServant._this(orb);

//用户名,密码

if (emsSessionFactory_I != null){

emsSessionFactory_I.getEmsSession("test","test", nmsSession, sessionHolder);

System.out.println("NMSsession ---" + nmsSession.toString()+"\nVersion:"+emsSessionFactory_I.getVersion());

emsSession = sessionHolder.value;

}

else{

return;

}

}catch (globaldefs.ProcessingFailureException ex) {

System.out.println("获取EmsSession引用对象,异常!---ProcessingFailureException---");

System.out.println("可能是用户名或者密码错误,或者权限不够[Corba OSS用户],或者已登陆的用户还未退出!");

System.out.println(ex.toString());

showMessage(ex.errorReason);

}

Common_IHolder common_IHolder = new Common_IHolder();

try {

//Retrieve List of Managers

managerNames_THolder supportedManagerList = new managerNames_THolder();

emsSession.getSupportedManagers(supportedManagerList);

String []managers=supportedManagerList.value;

for (int i = 0; i < managers.length; i++ )

{

System.out.print("Manager ");

System.out.print(i);

System.out.println(" " + managers[i]);

}

//返回所有网元

emsSession.getManager("ManagedElement",common_IHolder);

managedElementMgr=ManagedElementMgr_IHelper.narrow(common_IHolder.value);

ManagedElementList_THolder meList=new ManagedElementList_THolder();

ManagedElementIterator_IHolder meIt=new ManagedElementIterator_IHolder();

managedElementMgr.getAllManagedElements(how_many, meList, meIt);

ManagedElement_T[] me= meList.value;

for (int i = 0; i < me.length; i++ ) {

String nativeEMSName=me[i].nativeEMSName;

String procuctName=me[i].productName;

NameAndStringValue_T[] name=me[i].name;

showMessage(nativeEMSName+","+procuctName+","+name[0].name+"|"+name[0].value+","+name[1].name+"|"+name[1].value);

}

/*

//获取网元信息

emsSession.getManager("EquipmentInventory",common_IHolder);

equipmentInventoryMgr = EquipmentInventoryMgr_IHelper.narrow(common_IHolder.value);

emsHolder = new EMS_THolder();

NameAndStringValue_T[] meOrHolderName=new NameAndStringValue_T[2];

meOrHolderName[0]=new NameAndStringValue_T();

meOrHolderName[0].name="EMS";

meOrHolderName[0].value="Huawei/T2000";

meOrHolderName[1]=new NameAndStringValue_T();

meOrHolderName[1].name="ManagedElement";

meOrHolderName[1].value="3145790";

EquipmentOrHolderList_THolder eqList=new EquipmentOrHolderList_THolder();

EquipmentOrHolderIterator_IHolder eqIt=new EquipmentOrHolderIterator_IHolder();

start_time=new Date();

equipmentInventoryMgr.getAllEquipment(meOrHolderName, how_many, eqList, eqIt);

end_time=new Date();

System.out.println("getAllEquipment:"+start_time.toString()+"-"+end_time.toString());

EquipmentOrHolder_T[] equipments=eqList.value;

for (int i=0;i< equipments.length;i++ ){

try{

EquipmentHolder_T equipmentHolder=equipments[i].holder();

String holderType=equipmentHolder.holderType;

String nativeEMSName=equipmentHolder.nativeEMSName;

NameAndStringValue_T[] name=equipmentHolder.name;

showMessage(holderType+","+nativeEMSName+","+name[0].name+"|"+name[0].value+","+name[1].name+"|"+name[1].value);

}

catch(Exception e){

continue;

}

}

*/

/*

//查询网管系统中所有未结束的告警和未结束的TCA 事件

String[] excludeProbCauseList=new String[0];

PerceivedSeverity_T[] excludeSeverityList=new PerceivedSeverity_T[0];

EventList_THolder eventList=new EventList_THolder();

EventIterator_IHolder eventIt=new EventIterator_IHolder();

how_many=10;

start_time=new Date();

emsMgr.getAllEMSAndMEActiveAlarms(excludeProbCauseList, excludeSeverityList, how_many, eventList, eventIt);

end_time=new Date();

System.out.println("getAllEMSAndMEActiveAlarms:"+start_time.toString()+"-"+end_time.toString());

StructuredEvent[] events= eventList.value;

for (int i=0;i

Property[] propertyList= events[i].filterable_data;

showMessage("event:"+i);

for (int j=0;j

try{

showMessage(""+propertyList[j].name+","+ propertyList[j].value);

Object prop_obj=propertyList[j].value.extract_Object();

}

catch(Exception e){

continue;

}

}

}

*/

} catch (ProcessingFailureException e) {

System.out.println("Processing Exception" + e.getMessage());

e.printStackTrace();

showMessage(e.errorReason);

}

finally{

emsSession.endSession();

}

}

/**

* @param msg

* @throws UnsupportedEncodingException

* 编码转换,以显示中文

*/

public static void showMessage(String msg) throws UnsupportedEncodingException {

byte[] bytes=msg.getBytes("ISO-8859-1");

String rlt = new String(bytes, "GBK");

System.out.println(rlt);

}

public static String decodeText(String src) throws UnsupportedEncodingException {

byte[] bytes=src.getBytes("ISO-8859-1");

String rlt = new String(bytes, "GBK");

return rlt;

}

public static void main(String[] args) throws UnsupportedEncodingException {

testCorba();

}

}

/**

* 前提:

* 1.license支持Corba

* 2.Corba服务开启:12001,12002,12003端口

* 3.可正常访问系统的用户名及密码(该用户当前未登陆)

* 4.客户端程序所在客户机的IP在“访问控制列表”允许的范围内

*

*/

python华为corba接口_Huawei T2000 Corba 接口客户端开发相关推荐

  1. python数据接口设计_python之接口与归一化设计

    1接口 接口的概念: Java 语言中的接口很好的展现了接口的含义: IAnimal.java /* * Java的Interface很好的体现了我们前面分析的接口的特征: * 1)是一组功能的集合, ...

  2. python requests库api_Python+requests库发送接口入参为xml格式的接口请求

    一)接口入参准备: 入参: <?xml version="1.0" encoding = "UTF-8"?> duoceshi 123456 DwO ...

  3. 11小时 python自动化测试从入门到_从设计到开发Python接口自动化测试框架实战,资源教程下载...

    课程名称 从设计到开发Python接口自动化测试框架实战,资源教程下载 课程简介: 课程从接口基础知识入门,从抓包开始,到接口工具的运用,再到常见接口库.接口开发.Mock服务.unittest框架的 ...

  4. python locust api_干货 | 基于Locust的接口压测

    作者介绍:吴锋雷.PP云高级测试工程师,拥有10年业务研发和测试经验,目前负责SDK及相关产品的测试工作. 系统上线前一般要通过压力测试来判断下是否能承受预估的访问量,假设我们要测试的接口每天访问量是 ...

  5. Python快速使用jira模块调用Jira接口

    Python快速使用jira模块调用Jira接口 JIRA介绍: JIRA是Atlassian公司出品的项目与事务跟踪工具,被广泛应用于缺陷跟踪.需求收集.流程审批.任务跟踪.项目跟踪和敏捷管理等工作 ...

  6. python 测试用例管理 生成_python自动生成接口测试用例

    在python中Template可以将字符串的格式固定下来,重复利用. 同一套测试框架为了可以复用,所以我们可以将用例部分做参数化,然后运用到各个项目中. 代码如下: coding=utf-8 ''' ...

  7. jemeter python接口自动化测试平台_WEB接口开发与自动化测试基于PYTHON语言PDF_Python教程...

    资源名称:WEB接口开发与自动化测试 基于PYTHON语言 PDF 内容简介: <Web接口开发与自动化测试--基于Python语言>以接口测试为主线,以Web开发为切入点,全面介绍了We ...

  8. python调用webservice接口实例_python调用各种接口,webservice,c接口,com接口,socket协议方法...

    python调用webservice接口(SOAP) (2)调用示例: 需要先安装suds库:pip install suds from suds.client import Client #如果需要 ...

  9. python网站设计中接口的作用_python接口自动化(三)--如何设计接口测试用例(详解)...

    简介 上篇我们已经介绍了什么是接口测试和接口测试的意义.在开始接口测试之前,我们来想一下,如何进行接口测试的准备工作.或者说,接口测试的流程是什么?有些人就很好奇,接口测试要流程干嘛?不就是拿着接口文 ...

最新文章

  1. python的with用法(参考)
  2. Error -26612: HTTP Status-Code=500 (Internal Server Error) ...
  3. rcnn -fast rcnn-faster rcnn物体检测论文
  4. Python学习(变量与字符串)
  5. 分分钟甩Word几条街,Python编辑公式竟可以如此简单,你都知道吗?
  6. C11中gets()的函数被删除
  7. python面向对象(下)
  8. 传统营销与社会化营销的差距
  9. C语言 从入门到放弃
  10. 从java9共享内存加载modules说起
  11. Attention 二 创新篇
  12. Java是编译性语言还是解释型语言 ?
  13. Google Earth Engine——无人机影像进行分类处理
  14. 技术科普丨4Cell1感光芯片的应用
  15. 使用postgresql和Arcgis创建路网拓扑结构
  16. 2019阿里P7社招面试题泄露;《警察抓小偷》,几人能答出来?
  17. 电磁干扰的屏蔽方法~金属屏蔽效率
  18. chkdsk工具使用总结
  19. ODB学习笔记之基础环境搭建
  20. 电路分析笔记-电路模型

热门文章

  1. 《直播从零开始》SRS 安装与部署RTMP服务
  2. Cocos 帮助更多优秀移动游戏登上 Web 舞台
  3. 努力学习打卡Day16
  4. 图文短视频信息流开发总结(仿小红书, Instagram)
  5. Windows --- 模态对话框
  6. Oculus Home 客户端安装教程
  7. 中日教育专家携手 KOOV编程机器人教育解决方案发布
  8. PPT:一个PPT中怎么引入另一个PPT的源格式内容
  9. python 名片管理系统
  10. Web结构挖掘算法概述