java 调用华为北向接口 CORBA 接口

空清城 发布于 2014/08/13 19:02
阅读 3K+
收藏 0

@齐国隆冬强 你好,想跟你请教个问题:

我的java代码是这样的


package clinet;
 
import java.io.UnsupportedEncodingException;
import java.util.Date;
 



import managedElementManager.ManagedElementMgr_I;
import nmsSession.NmsSession_I;
import nmsSession.NmsSession_IPOA;
import notifications.EventIterator_IHolder;
import notifications.EventList_THolder;
import notifications.PerceivedSeverity_T;
 



import org.omg.CORBA.IntHolder;
import org.omg.CORBA.ORB;
import org.omg.CORBA.SystemException;
import org.omg.CosNaming.NamingContextExt;
import org.omg.CosNaming.NamingContextExtHelper;
import org.omg.PortableServer.POA;
 



import CosNaming.NameComponent;
import CosNaming.NamingContext;
import CosNaming.NamingContextHelper;
import CosNotification.Property;
import CosNotification.StructuredEvent;
 
import common.Common_IHolder;
 
import emsMgr.EMSMgr_I;
import emsMgr.EMS_T;
import emsMgr.EMS_THolder;
import emsSession.EmsSession_I;
import emsSession.EmsSession_IHolder;
import emsSessionFactory.EmsSessionFactory_I;
import emsSessionFactory.EmsSessionFactory_IHelper;
import equipment.EquipmentInventoryMgr_I;
import globaldefs.ProcessingFailureException;
import helloapp.HelloHelper;
 
public class CorbaClientPtnHw {   
    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 main(String[] args) {
        //建立连接登录、建立消息通道    
        try {    
            String[] args1 = new String[2];   
            args1[0] = "-ORBInitRef ";   
            args1[1] = "NameService=corbaloc::10.209.121.94:12001/NameService";        
            orb = org.omg.CORBA.ORB.init(args1, null);    
        } catch (SystemException ex) {     
            System.out.println("初始化ORB对象异常!");    
        }     
 
      
        org.omg.CORBA.Object objRef = null;   
               NamingContext ncRef=null;
        try {    
            objRef = orb.resolve_initial_references("NameService");   
            ncRef = NamingContextHelper.narrow(objRef);   
            System.out.println("获取取名字服务成功:"+ncRef);
            
        }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/U2000","EmsInstance");
        path[3] = new NameComponent("2.0","Version");
        path[4] = new NameComponent("Huawei/U2000","EmsSessionFactory_I");
 
        EmsSessionFactory_I emsSessionFactory_I = null;
        org.omg.CORBA.Object obj = null;
    
            obj= ncRef.resolve(path);
            System.out.println("obj=>"+obj);
            emsSessionFactory_I = EmsSessionFactory_IHelper.narrow(obj);
            System.out.println("emsSessionFactory_I=>"+emsSessionFactory_I);

      
        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 {   
 
             
 
 
             
            //查询网管系统中所有未结束的告警和未结束的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();
            int 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<events.length;i++){                
                Property[] propertyList= events[i].filterable_data;
                showMessage("event:"+i);
                for (int j=0;j<propertyList.length;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();
        }
}

    private static void showMessage(String errorReason) {
    
        System.out.println("aaaaaaaa");
        
    }
}


问题 : 当我黄色部分为5个参数的时候 

       path[0] = new NameComponent("TMF_MTNM","Class");
        path[1] = new NameComponent("HUAWEI","Vendor");
        path[2] = new NameComponent("Huawei/U2000","EmsInstance");
        path[3] = new NameComponent("2.0","Version");
        path[4] = new NameComponent("Huawei/U2000","EmsSessionFactory_I");

运行到这里      obj= ncRef.resolve(path); 会给我报如下错误


CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0
    at CosNaming.NamingContextPackage.NotFoundHelper.read(NotFoundHelper.java:72)
    at CosNaming._NamingContextStub.resolve(_NamingContextStub.java:151)
    at clinet.CorbaClientPtnHw.main(CorbaClientPtnHw.java:93)

也就是 CosNaming.NamingContextPackage.NotFound的错误,试过很多方法都么有办法解决.

当参数为2个的时候  obj= ncRef.resolve(path); 这个可以运行可以得到obj的值

但是这个值放到后面做参数的时候    emsSessionFactory_I = EmsSessionFactory_IHelper.narrow(obj);提示参数不
  所以我想在问一下

       path[0] = new NameComponent("TMF_MTNM","Class");
        path[1] = new NameComponent("HUAWEI","Vendor");
        path[2] = new NameComponent("Huawei/U2000","EmsInstance");
        path[3] = new NameComponent("2.0","Version");
        path[4] = new NameComponent("Huawei/U2000","EmsSessionFactory_I");

这里面中的TMF_MTNM 这些值是固定的吗 >??








加载中
0
齐国隆冬强
齐国隆冬强

是双方定好的命名空间,作为客户端,你可以问下对方是不是这样配置的。

http://www.pa.msu.edu/reference/jdk-1.2.2-docs/guide/idl/jidlNaming.html

这篇文章可以帮你理解一下。

空清城
空清城
恩 谢谢
0
叶落花开
叶落花开
亲,有没有NmsSessionImpl.java的源码啊?求~
叶落花开
叶落花开
回复 @空清城 : 亲 还在么?
叶落花开
叶落花开
回复 @空清城 : 我已经编译得到了,谢谢
空清城
空清城
今天 才看到你的消息 ,,现在还需要么 。
0
永生天子
永生天子

老铁,你有没有通过SSL连接corba的例子?

OSCHINA
登录后可查看更多优质内容
返回顶部
顶部