1

我正在为 Corba 服务器编写 C# 客户端,我正在使用 IIOP.NET,通过以下页面上的示例进行操作:http: //iiop-net.sourceforge.net/rmiAdderDNClient.html

我已经做到了这一点,没有错误:

// Register channel
IiopClientChannel channel = new IiopClientChannel();
ChannelServices.RegisterChannel(channel, false);

// Access COS naming context
CorbaInit init = CorbaInit.GetInit();
NamingContext context = init.GetNameService(host, port);

变量“host”是一个带有服务器计算机名称的字符串,“port”是一个表示端口号的 int。其他系统当前使用这些值连接到服务器,因此我可以确认它们是正确的。

但是,尝试连接到交易者服务会在运行时产生异常。这是我用来执行此操作的代码:

// Looking up VB Trader
NameComponent[] names = new NameComponent[] { new NameComponent("TraderInterface") };
object obj = context.resolve(names);

这是我收到的错误消息:

“CORBA 系统异常:omg.org.CORBA.INV_OBJREF,已完成:Completed_No 次要:10102。”

这似乎暗示了一个无效的对象引用,但这意味着什么?我传递给解析方法的字符串格式是否不正确?我尝试了许多与其他系统中使用的服务不同的名称,但我总是得到相同的错误,这让我怀疑我是否正确解释了它。

顺便说一句,在我绝望的情况下,我还尝试从 IOR 获取对象引用,但这又引发了一个不同的异常(即 omg.org.CORBA.ORB_package.InvalidName)。

OrbServices orb = OrbServices.GetSingleton();
object obj = orb.resolve_initial_references(traderIOR);

欢迎任何建议。

4

1 回答 1

2

我永远无法使用上述任何方法访问我的服务器,但是以下代码最终使通信正常工作:

Hashtable props = new Hashtable();
props[IiopChannel.BIDIR_KEY] = true;
props[IiopServerChannel.PORT_KEY] = port;

// register corba services
IiopChannel channel = new IiopChannel(props);
ChannelServices.RegisterChannel(channel, false);

MyInterface obj = (MyInterface)RemotingServices.Connect(typeof(MyInterface), ior);

我不完全确定为什么我必须使用这种(看似)非常规的方式。可能是由于缺少在服务器上运行的命名服务。不管是什么原因,我希望这可以帮助那里的人。

于 2012-06-15T13:11:04.303 回答