[Enterprise Extensions only]

ORB::resolve_initial_references_remote

Overview Obtains an object reference to the Naming Service.
Original class CORBA::ORB
Exceptions If the input identifier is not valid, a CORBA::ORB::InvalidName exception is thrown.
If another error occurs, a CORBA::SystemException is thrown.


Intended Usage

The CORBA::ORB::resolve_initial_references_remote method is intended to be used by client and server applications to obtain a reference to a NameService object from an input list of host names and associated port numbers.

The return result is the first root name context of a naming tree located from the input list of hosts. The returned object should be narrowed to CosNaming::NamingContext (or some class derived from it).

IDL Syntax

   CORBA::Object_ptr resolve_initial_references_remote
      (const char * identifier,
       const CORBA::ORB::remote_modifier  host_port_list );

Input parameters

identifier
The non-NULL identifier of the Naming Service object reference to be obtained. This string must be "NameService".
host_port_list

This is a list of host names and associated port numbers on which the resolve_initial_references_remote operation will attempt to locate a NameService object. The operation will return the first NameService object located from the host and port combinations provided in the list.

Each string representing a hostname and port combination must be of the following syntax:

  iiop://HostName:PortNumber

Return values

CORBA::Object_ptr
A reference to the requested Naming Service is returned. The caller assumes ownership of the returned object reference, and should subsequently release it using CORBA::release.

Example

  #include "corba.h"
  ...
  //-------------------------------------
  // - assume the ORB object pointer
  //   has already been initialized . . .
  //-------------------------------------
  extern CORBA::ORB_ptr op;
 
  CORBA::Object_ptr     optr = NULL;
  CORBA::String_var     naming_objectid = CORBA::string_dup ("NameService");
 
  //---------------------------------
  // - create a host port list and
  //   provide room for three entries 
  //---------------------------------
  CORBA::ORB::remote_modifier     host_port_list;
  host_port_list.length (3);
 
  //---------------------------------------
  // - initialize the host port list 
  //   with three host name and port number
  //   combinations . . .
  //---------------------------------------
  host_port_list [0] = CORBA::string_dup ("iiop://hostName1:900");
  host_port_list [1] = CORBA::string_dup ("iiop://hostName2:3003");
  host_port_list [2] = CORBA::string_dup ("iiop://hostName3:900);
 
  optr = op-> resolve_initial_references_remote (naming_objectid,
    host_port_list);
 
  if (optr != NULL)
  {
     //----------------------------------------------------------------
     // - narrow the object to the appropriate object type
     // - release the object (_narrow performs a _duplicate)
     //------------------------------------------------
     optr = CORBA::CosNaming::NamingContext::_narrow (optr);
     CORBA::release (optr);
  }
  ...