我正在尝试建立与华为U2000 NBI corba的连接,以使用.ior文件进行连接以获取警报。我已经将IDL文件编译为Java。下面是我初始化ORB的主要代码

package com.be.u2k;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;

import org.omg.CORBA.ORB;

import AlarmIRPSystem.AlarmIRP;
import AlarmIRPSystem.AlarmIRPHelper;

public class Main {

    public static void main(String[] args) {

        try {
          String filename = System.getProperty ("user.home") + System.getProperty ("file.separator")+"u2k.ior";

          File f = new File(filename);

          if (!f.exists()) {
            System.out.println("File " + filename + " does not exist.");
            System.exit(-1);
          } else if (f.isDirectory()) {
            System.out.println("File " + filename + " is a directory.");
            System.exit(-1);
          }

          BufferedReader br = new BufferedReader(new FileReader(f));
          String iorContents = br.readLine();
          br.close();

          ORB orbWithIor = ORB.init(args, null);
          org.omg.CORBA.Object obj = orbWithIor.string_to_object(iorContents);

          AlarmIRP alarmIrp = AlarmIRPHelper.narrow(obj);
          System.out.println("AlarmIRPHelper.narrow success!") ;
        } catch (Exception e) {
          System.out.println("ERROR : " + e) ;
          e.printStackTrace(System.out);
        }
    }
}


为什么在运行BAD_PARAM时仍然出现错误

java -jar ServerU2kAlarm.jar

admin@ip-10-44-0-10:~$ java -jar ServerU2kAlarm.jar
ERROR : org.omg.CORBA.BAD_PARAM:   vmcid: 0x0  minor code: 0  completed: No
org.omg.CORBA.BAD_PARAM:   vmcid: 0x0  minor code: 0  completed: No
    at AlarmIRPSystem.AlarmIRPHelper.narrow(AlarmIRPHelper.java:60)
    at com.be.u2k.Main.main(Main.java:36)


我是否错过了ORB对象的任何东西?谢谢。

最佳答案

我现在正在处理相同的问题。首先,您必须为HW U2000获得EPIRP。这是示例代码AlarmIRP.Code尚未完成。要获得要使用的服务的IOR,必须在get_IRP_reference方法中给出相关的irpId和irpClassName。

对于managerIdentifier,请阅读以下说明:managerIdentifier value

Image for HW U2000 Relations between IRPs

        ***
        Properties properties = new Properties();
        properties.put("org.omg.CORBA.ORBClass", "org.jacorb.orb.ORB");
        properties.put("org.omg.CORBA.ORBSingletonClass", "org.jacorb.orb.ORBSingleton");
        properties.put("ORBInitRef.NameService", settings.getIorString());

        // Connect to name service
        ORB orb = ORB.init((String[]) null, properties);
        POA poa = POAHelper.narrow(orb.resolve_initial_references(settings.getRootPoaName()));
        poa.the_POAManager().activate();
        logger.info("ORB init success");

        org.omg.CORBA.Object obj = orb.string_to_object(settings.getIorString());

        String epirpVersion = null;
        String systemDn = null;
        String irpId = null;
        String irpClassName = null;
        EPIRP epirp = EPIRPHelper.narrow(obj);
        String[] epirpVersions = epirp.get_EP_IRP_versions();
        for (String str : epirpVersions) {
            if (null != str && !"".equals(str.trim())) {
                epirpVersion = str;
            }
        }

        SupportedIRPListTypeHolder supportedIrpList = new SupportedIRPListTypeHolder();
        if (ResultType._OK == epirp.get_IRP_outline("", supportedIrpList).value()) {
            SupportedIRPListTypeElement[] typeHolder = supportedIrpList.value;
            for (SupportedIRPListTypeElement irpListEle : typeHolder) {
                systemDn = irpListEle.systemDN;

                logger.info("dnType:    " + systemDn);
                for (IRPElement irpElement : irpListEle.irpList) {
                    irpId = irpElement.irpId;
                    logger.info("irpId: " + irpId);
                    irpClassName = irpElement.irpClassName;
                    logger.info("irpClassName: " + irpClassName);
                    logger.info("irpVersion: " + irpElement.irpVersion);
                    logger.info("irpManagementScope: ");
                    for (String s : irpElement.irpManagementScope.value()) {
                        logger.info(s);
                    }
                }
            }
        } else {
            logger.error("Failed");
        }

        StringHolder alarmIrpIOR = new StringHolder();
        epirp.get_IRP_reference(managerIdentifier, systemDn, irpId, irpClassName, alarmIrpIOR);
        logger.info("AlarmIRP:" + alarmIrpIOR.value);

        //Connect to AlarmIRP
        AlarmIRP alarmIRP = AlarmIRPHelper.narrow(orb.string_to_object(alarmIrpIOR.value));

10-06 14:42