Hi,
in the course of writing this message I resolved my problem. However, I decided
to post it here for others to see; you may ignore it if you like.
----
I have a Java server program connected to the VisiBroker (4.5)
NameService which registers an object "AccountManager". That works!
I only have to submit the command line parameter "-ORBInitRef
NameService=corbaloc:iiop:1.2@127.0.0.1:2500/NameService" to my Java
server.
I can see the object under the NameService item in the VisiBroker console.
Both osagent and the nameserver are running.
The problem is, how do I access the object using a Delphi client? The IDL is:
module Bank {
interface AccountManager {
float open(in string name);
};
};
I have created a Delphi server and client which work fine together! No problem
there. However, when I start the BankServer program it doesn't seem to use the
naming service, instead I see the registered object under the
"Location Service", "Object Instances" tab. The object's
name is IDL:Bank/AccountManager:1.0, which is fine because that's how it's
registered by the server.
When I use my Java server, though, the object does not appear under the
Location Service, but under the Naming Service. Its name, however, is exactly
the same: IDL:Bank/AccountManager:1.0.
If I connect from my client now, I get an exception OBJECT_NOT_EXIST.
The code I use is:
am : AccountManager;
...
am := TAccountManagerHelper.Bind;
which does
class function TAccountManagerHelper.Bind(const _InstanceName : string = '';
_HostName: string = '') : Bank_i.AccountManager;
begin
Result := Narrow(ORB.bind(RepositoryId, _InstanceName, _HostName),
True);
end;
and RepositoryId yields
Result := 'IDL:Bank/AccountManager:1.0';
I have tried different parameters for "bind", such as
am := TAccountManagerHelper.Bind('NameService', 'localhost');
as well as passing command line parameters like
"-ORBInitRef
NameService=corbaloc:iiop:1.2@127.0.0.1:2500/NameService"
but all to no avail. If I start the client with command line parameters like
"-ORBInitialPort=2500", I get either EEFFACE exceptions or an access
violation followed by a runtime error 216.
I found the solution in a Delphi 7 example: Demos\Corba\Idl2Pas\CosNaming40
I should have connected to the Naming Service as follows:
var
RootContext : NamingContext;
nameComp : NameComponent;
nameArray : COSNaming.Name;
...
//bind to the Root Context of the NS via the orb
RootContext :=
TNamingContextHelper.Narrow(Orb.ResolveInitialReferences('NameService'),
True);
//create the naming component -- match server id and kind values
nameComp := TNameComponent.Create('AccountManager', '');
//set up the Name sequence
SetLength(NameArray, 1);
NameArray[0] := nameComp;
//Resolve the account manager object
am := TAccountManagerHelper.narrow(RootContext.resolve(NameArray),
True);
By the way, the VisiBroker console (and maybe all of the vbj client programs)
requires the vbj cmd line option "-VBJjavavm
c:\jdk13\jre\bin\java.exe" to run. Otherwise they just print the
synopsis. Now guess how long it took me to find that out! :-( I haven't yet
figured out how to start the other services which come with their own
launchers. Information about these is very hard to come by.
Thanks for all the folks who read this, this is only my third day doing CORBA
and I already wanted to throw the farking %&§& into the recycler!
It's great, though,