尝试使用 corbaloc url 连接到 CORBA 服务

发布于 2024-08-31 12:52:00 字数 423 浏览 4 评论 0原文

    String[] orbargs= {};
    org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(orbargs, null);
    org.omg.CORBA.Object cobj = orb.string_to_object("corbaloc:iiop:10.1.1.200:6969/OurServiceHelper");
    _OurServiceHelper cpsh = _OurServiceHelperHelper.narrow(cobj); // Get's stuck
    cpsh.ourMethod();

那个狭窄的地方就挂着。

我的服务设置为在静态端口上运行。我们知道它是有效的,因为我们通常通过 NamingService 查找它。

我做错了什么?

    String[] orbargs= {};
    org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(orbargs, null);
    org.omg.CORBA.Object cobj = orb.string_to_object("corbaloc:iiop:10.1.1.200:6969/OurServiceHelper");
    _OurServiceHelper cpsh = _OurServiceHelperHelper.narrow(cobj); // Get's stuck
    cpsh.ourMethod();

That narrow just hangs.

My service is setup to run on a static port. And we know it works since we usually look it up through the NamingService.

What am I doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

浅忆 2024-09-07 12:52:00

如果您使用 NamingService,则实际上应该使用 corbaname url 而不是 corbaloc url。如果您的命名服务位于端口 6969,则以下内容将起作用。如果“OurServiceHelper”位于 6969,但 NamingService 位于不同端口,则您需要在下面的 url 中指定命名服务的端口,而不是 6969。服务器对象嵌入在 NamingService 返回的 ior 中,因此不需要指定它。

"corbaname:10.1.1.200:6969#OurServiceHelper"

回复:评论:
首先是关于 IOR 和提供对象的注释。如果您希望所服务的对象在进程重新启动后保持不变,则必须在包含这些对象的 POA 上设置PERSISTENT生命周期策略。此外,IOR 嵌入了服务器的 IP 和端口,因此如果您希望生成在重新启动后保持一致的 IOR,则必须使用静态 IP 和端口号以及使用持久生命周期策略。

名称服务使事情变得更容易,让您不必担心很多这样的事情。只要可以在已知位置访问名称服务,所有服务器对象都可以在实例化时向名称服务注册自己,然后客户端可以访问它们,而无需知道它们所在的位置。

如果您决定不使用名称服务,则必须对代码进行一些更改。如果您使用 corbalocurl,那么您正在使用互操作命名服务 (INS)。请参阅: http://java.sun.com/ j2se/1.4.2/docs/guide/idl/INStutorial.html。使用INS,您需要使用NamingContextExt对象的功能。具体来说,要解析您构造的 corabloc url,您应该调用 NamingContextExt::resolve_str 函数并传入 url。

If you're using the NamingService, you should actually be using a corbaname url instead of a corbaloc url. The below will work if your naming service is on port 6969. If "OurServiceHelper" is on 6969 but the NamingService is on a different port, you need to specify the port of the naming service in the url below instead of 6969. The port of the server object is embedded in the ior returned by the NamingService so that's why it doesn't need to be specified.

"corbaname:10.1.1.200:6969#OurServiceHelper"

Re: Comment:
First a note about IORs and serving up objects. If you want your served objects to be persistent across process restarts, you have to set the PERSISTENTlifetime policy on the POA that contains the objects. Also, the IOR embeds the ip and port of the server, so if you want to generate IORs that remain consistent across restarts you have to use a static IP and port number as well as using the persistent lifetime policy.

The name service makes things easier by allowing you not to have to worry about a lot of this stuff. As long as the name service is reachable at a known location, all of your server objects can just register themselves with the name service when they are instantiated and clients can then access them without having to know where they're located.

If you're determined not to use the name service you're code will have to change somewhat. If you use the corbalocurl then you are using the Interoperable Naming Service (INS). See: http://java.sun.com/j2se/1.4.2/docs/guide/idl/INStutorial.html. Using the INS, you need to use the functionality of the NamingContextExt object. Specifically, to resolve the corabloc url that you construct you should call the NamingContextExt::resolve_strfunction and pass in the url.

蓝天白云 2024-09-07 12:52:00

corbaloc URL 的关键部分(斜杠后面的字符串)可能不正确或未正确注册,并且服务器端 orb 无法将键映射到对象引用。

你如何运行服务器?

这应该可行:

<server> -ORBInitRef OurServiceHelper="file://server.ior"

因此,当 corbaloc 请求传入时,orb 应该能够将密钥与 ior 相匹配并返回 ior。不同的 ORB 有不同的方法来注册初始引用,例如 TAO 有一个名为 IORTable 的专有接口。

The key part of the corbaloc URL (string after the slash), could possibly be incorrect or not registered correctly, and the serverside orb isn't able to map the key to the object reference.

How are you running the server?

This should work:

<server> -ORBInitRef OurServiceHelper="file://server.ior"

So when the corbaloc request comes in the orb should be able to match the key to the ior and return you the ior. Different ORB's have different ways of doing this for registering an initial reference, TAO have a propriety interface called IORTable for example.

请止步禁区 2024-09-07 12:52:00

corbaloc 中没有类型信息,因此 ORB 正在通过远程调用 (_is_a) 检查您要缩小的类型。尝试使用未经检查的狭窄,它不会调用 _is_a:

_OurServiceHelper cpsh = _OurServiceHelperHelper.narrow(cobj);

奇怪的是 _is_a 调用没有为您返回。我的猜测是 unchecked_narrow 会起作用(您将得到一个非空结果),但对象引用不起作用。

The corbaloc has no type info in it, so the ORB is checking the type you're narrowing to by making a remote call (_is_a). Try using an unchecked narrow, which won't call _is_a:

_OurServiceHelper cpsh = _OurServiceHelperHelper.narrow(cobj);

It's odd that the _is_a call doesn't return for you. My guess is that the unchecked_narrow will work work (you'll get a non-null result), but the object reference won't work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文