Uses the CORBA naming service API to obtain the initial naming context for an EAServer component.
This function is used by PowerBuilder clients connecting to EAServer.
JaguarORB objects
jaguarorb.Resolve_Initial_References ( objstring, object )
Argument |
Description |
---|---|
jaguarorb |
An instance of JaguarORB |
objstring |
A string that has the value "NameService" |
object |
A reference variable of type CORBAobject that will contain a reference to the COS naming service |
Long. Returns 0 if it succeeds and a negative number if an error occurs.
If you want to use the Jaguar naming service API, you can use the Resolve_Initial_References function to obtain the initial naming context. However, this technique is not recommended because it requires use of a deprecated SessionManager::Factory create method. Most PowerBuilder clients do not need to use the CORBA naming service explicitly. Instead, they can rely on the name resolution that is performed automatically when they create EAServer component instances using the CreateInstance and Lookup functions of the Connection object.
You can also use the JaguarORB object’s String_To_Object function to instantiate a proxy instance without using the CORBA naming service explicitly. For more information about connecting to EAServer using the JaguarORB object, see Application Techniques.
When you use the CORBA naming service, you need to generate proxies for the naming service interface and include these proxies in the library list for the client.
The following example shows the use of the Resolve_Initial_References function to obtain an initial naming context. After obtaining the naming context, it uses the naming context’s resolve method to obtain a reference to a Factory object for the component and then narrows that reference to the SessionManager’s Factory interface.
The resolve method takes a name parameter, which is a sequence of NameComponent structures. Each NameComponent structure has an id attribute that identifies the component and a kind attribute that can be used to describe the component. In the example below, the name has only one component. The create method of the Factory object obtains proxies for the component. It returns a CORBA object reference that you can convert into a reference to the component’s interface using the _Narrow function.
The NamingContext and NameComponent types used in the example are proxies imported from the CosNaming package in EAServer, and the Factory type is imported from the SessionManager package:
CORBAObject my_corbaobj
JaguarORB my_orb
NamingContext my_nc
NameComponent the_name[]
Factory my_Factory
n_jagcomp my_jagcomp
my_orb = CREATE JaguarORB
// Enclose the name of the URL in single quotes
my_orb.init("ORBNameServiceURL='iiop://server1:2000'")
my_orb.Resolve_Initial_References("NameService", &
my_corbaobj)
my_corbaobj._narrow(my_nc, &
"omg.org/CosNaming/NamingContext")
the_name[1].id = "mypackage/n_jagcomp"
the_name[1].kind = ""
TRY
my_corbaobj = my_nc.resolve(the_name)
my_corbaobj._narrow(my_Factory, & "SessionManager/Factory")
my_corbaobj = my_Factory.create("jagadmin","")
my_corbaobj._narrow(my_jagcomp, & "mypackage/n_jagcomp")
CATCH (Exception e) MessageBox("Exception Raised!", e.getMessage()) END TRY
my_jagcomp.getdata()