首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

急真心求教华为U2000的连接有关问题

2012-01-02 
急,真心求教华为U2000的连接问题我现在需要做一个项目,需要利用华为的U2000去开通传输电路,现在在连接U200

急,真心求教华为U2000的连接问题
我现在需要做一个项目,需要利用华为的U2000去开通传输电路,现在在连接U2000的时候出现了问题,我是利用网上连接T2000的代码去连接T2000的,在获取emssession时出现错误。代码如下:
import org.omg.CORBA.ORB;  
import org.omg.CORBA.SystemException;  
  
import CosNaming.NameComponent;  
import CosNaming.NamingContext;  
import CosNaming.NamingContextHelper;  
import emsMgr.EMSMgr_I;  
import emsSession.EmsSession_I;  
import emsSession.EmsSession_IHolder;  
import emsSessionFactory.EmsSessionFactory_I;  
import emsSessionFactory.EmsSessionFactory_IHelper;
import nmsSession.*;
import common.*;
import emsMgr.*;
import org.omg.PortableServer.POAPackage.ServantAlreadyActive;
import org.omg.PortableServer.POAPackage.WrongPolicy;
  
public class Client_start {  
  static ORB orb;  
  static EMSMgr_I emsMgr = null;  
  static EmsSession_I emsSession=null;  
   
  public static void testTai(){  
  //建立连接登录、建立消息通道  
  try {  
  String[] args = new String[2];  
  args[0] = "-ORBInitRef";  
  args[1] = "NameService=corbaloc::132.232.4.130:12001/NameService";  
  
  orb = org.omg.CORBA.ORB.init(args, null);  
   
  } catch (SystemException ex) {  
  System.out.println("初始化ORB对象异常!");  
  }  
  
  //NameService  
  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();  
  }  
  
  //EMSSessionFactory
  NameComponent tmfClass = new NameComponent("TMF_MTNM", "Class");
NameComponent tmfVendor = new NameComponent("HUAWEI", "Vendor");
NameComponent tmfEmsInstance = new NameComponent("Huawei/U2000","EmsInstance");
NameComponent tmfVersion = new NameComponent("2.0", "Version");
NameComponent tmfEntity = new NameComponent("Huawei/U2000","EmsSessionFactory_I");  
  //NameComponent nc = new NameComponent("Huawei/U2000", "EmsSessionFactory_I");  
  NameComponent path[] = { tmfClass, tmfVendor, tmfEmsInstance,tmfVersion, tmfEntity };;  
   
  EmsSessionFactory_I emsSessionFactory_I = null;  
  org.omg.CORBA.Object obj = null;  
  try{  
  obj = namingContext.resolve(path);  
  System.out.println("orb"+obj);  
  emsSessionFactory_I = EmsSessionFactory_IHelper.narrow(obj);  
  System.out.println("成功获得EmsSessionFactory"+emsSessionFactory_I);  
  }catch(Exception e){  
  e.printStackTrace();  
  }  
  
  EmsSession_IHolder sessionHolder = new EmsSession_IHolder();  
try {  
 


NmsSession_I nmsSession = null;  
//用户名,密码  
emsSessionFactory_I.getEmsSession("xwtech","hwfx456!!", nmsSession, sessionHolder);  
System.out.println("NMSsession ---" + nmsSession.toString());  
}catch (globaldefs.ProcessingFailureException ex) {  
System.out.println("获取EmsSession引用对象,异常!---ProcessingFailureException---");  
System.out.println("可能是用户名或者密码错误,或者权限不够,或者已登陆的用户还未退出!");  
System.out.println(ex.toString());  
}  
emsSession = sessionHolder.value;  
 
Common_IHolder common_IHolder = new Common_IHolder();  
try {  
emsSession.getManager("emsMgr", common_IHolder);  
emsMgr = EMSMgr_IHelper.narrow(common_IHolder.value);  
} catch (globaldefs.ProcessingFailureException e) {  
e.printStackTrace();  
}  
  }  
   
  public static void main(String[] args){  
  testTai();  
// Thread corba = new Thread(new Client(),"corba");  
// corba.start();  
  }  
}

现在在emsSessionFactory_I.getEmsSession("xwtech","hwfx456!!", nmsSession, sessionHolder);出现错误,
globaldefs.ProcessingFailureException: IDL:mtnm.tmforum.org/globaldefs/Processi
gFailureException:1.0
Exception in thread "main" java.lang.NullPointerException
  at Client_start.testTai(Client_start.java:84)
  at Client_start.main(Client_start.java:92)

请问这是什么问题,前面的执行都能执行成功,能够获得orb,EmsSessionFactory等,直到最后一步出现错误,是不是有可能是用户名密码的问题?这是华为那边提供的。

[解决办法]
NmsSession_I nmsSession = null;//不能这样
看看下面代码:
POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
rootpoa.the_POAManager().activate();
NmsSession_I nmsSessionImpl = new NmsSession_Impl();
NmsSession_I csession = null; 

NmsSession_IPOATie tie = new NmsSession_IPOATie(nmsSessionImpl,rootpoa);
csession = tie._this(orb);

org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");

NamingContext namingContext = NamingContextHelper.narrow(objRef);
System.out.println(namingContext);

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

org.omg.CORBA.Object obj;
obj = namingContext.resolve(name);

System.out.println(obj);

//获取EmsSession 的对象引用并登录

EmsSession_IHolder emssession_holder = new EmsSession_IHolder();

EmsSessionFactory_I sfobj = EmsSessionFactory_IHelper.narrow(obj);

sfobj.getEmsSession("corba1111","admin1234",csession,emssession_holder);

System.out.println(csession);

emsSession = emssession_holder.value;

热点排行