[omniORB] OrbixNames <-> omniORB interoperability

Borges, Mark mark.borges@attws.com
Wed, 15 Mar 2000 13:09:15 -0800


I am encountering a potential problem getting OrbixMT-2.3.4 and
OrbixNames-1.1c02 to work with omniORB-2.8.0 (with latest
patches). Specifically, it appears I'm experiencing the infamous 
"_" vs "/" Type ID problem (but I thought it was resolved in these
latest versions from IONA).

For example, here is the output of the demo/simple/Client.cc program
bundled with OrbixNames:

-----------------------------------------------------------------------
Simple1 demo start
[ s1224: OrbixNames (Release 1.1c02) ]
IOR:000100000000002849444c3a6f6d672e6f72672f436f734e616d696e672f4e616d696e67
436f6e746578743a312e3000000000010000000000000060000100000000001670687265642e
6e776573742e61747477732e636f6d0006220000003c3a5c70687265642e6e776573742e6174
7477732e636f6d3a4e533a726f6f743a3a49523a436f734e616d696e675f4e616d696e67436f
6e7465787400

Name Foo1 in the root context resolved to
IOR:000000010000001049444c3a6261722f666f6f3a312e300000000001000000000000004f
000100000000001670687265642e6e776573742e61747477732e636f6d0086d00000002b3a5c
70687265642e6e776573742e61747477732e636f6d3a383635343a303a3a49523a6261725f66
6f6f00 as expected

Name Foo2 in the root context resolved to
IOR:000000010000001049444c3a6261722f666f6f3a312e300000000001000000000000004f
000100000000001670687265642e6e776573742e61747477732e636f6d0086d00000002b3a5c
70687265642e6e776573742e61747477732e636f6d3a383635343a313a3a49523a6261725f66
6f6f00 as expected
Simple1 demo end
-----------------------------------------------------------------------

These IOR's generated by the Client.cc code and
OrbixMT-2.3.4/OrbixNames-1.1c02 appear to be OMG compliant,

-----------------------------------------------------------------------
$ /opt/omniORB/bin/catior
IOR:000000010000001049444c3a6261722f666f6f3a312e300000000001000000000000004f
000100000000001670687265642e6e776573742e61747477732e636f6d0086d00000002b3a5c
70687265642e6e776573742e61747477732e636f6d3a383635343a303a3a49523a6261725f66
6f6f00
Type ID: "IDL:bar/foo:1.0"                                       
Profiles:
1. IIOP 1.0 phred.nwest.attws.com 34512
":\phred.nwest.attws.com:8654:0::IR:bar_foo."
-----------------------------------------------------------------------

However, when I configure omniORB to use the OrbixNames NAMESERVICE in
/etc/omniORB.cfg and ask for the IOR, I get instead:

-----------------------------------------------------------------------
$ /opt/omniORB/bin/nameclt list
test.my_context/
ObjectGroups/
list: Unexpected error encountered.

$ /opt/omniORB/bin/nameclt resolve test.my_context/Foo1
IOR:000000000000001049444c3a6261725f666f6f3a312e300000000001000000000000004f
000100000000001670687265642e6e776573742e61747477732e636f6d0086d00000002b3a5c
70687265642e6e776573742e61747477732e636f6d3a383635343a303a3a49523a6261725f66
6f6f00

$ /opt/omniORB/bin/catior
IOR:000000000000001049444c3a6261725f666f6f3a312e300000000001000000000000004f
000100000000001670687265642e6e776573742e61747477732e636f6d0086d00000002b3a5c
70687265642e6e776573742e61747477732e636f6d3a383635343a303a3a49523a6261725f66
6f6f00
Type ID: "IDL:bar_foo:1.0"
Profiles:
1. IIOP 1.0 phred.nwest.attws.com 34512
":\phred.nwest.attws.com:8654:0::IR:bar_foo."
-----------------------------------------------------------------------

In particular, note the bogus Type ID,

  Type ID: "IDL:bar_foo:1.0"
            ^^^^^^^^^^^^^^^^

Why?

This is reminiscent of the previously reported Orbix <-> omniORB
interoperability problem found in the archives, e.g.,

  http://www.uk.research.att.com/omniORB/archives/1999-03/0102.html
  http://www.uk.research.att.com/omniORB/archives/1999-03/0100.html
  http://www.uk.research.att.com/omniORB/archives/1997-10/0030.html

Is this still a problem? Can anyone on this list report success using
a similar version of Orbix (2.3.4 and 1.1c02)?

For completeness, appended is the foo.idl definition, and the
Client.cc program (mostly taken from the demo/ subdirectory of the
OrbixNames-1.1c02 distribution).
 
-----------------------------------------------------------------------

//                 Copyright (c) 1996-7 IONA Technologies PLC
//                          All Rights Reserved
//
//              THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF 
//                          IONA Technologies PLC
//
//              The copyright notice above does not evidence any
//              actual or intended publication of such source code.
//


//
// Simple interface for demonstration of the COSS Naming Service
//
module bar {
        interface foo {
                void func();
        };
};

-----------------------------------------------------------------------
// CORBAServices Naming Service, simple example 1.
// 
//                 Copyright (c) 1996-7 IONA Technologies PLC
//                          All Rights Reserved
//
//		THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF 
//			    IONA Technologies PLC
//
//		The copyright notice above does not evidence any
//		actual or intended publication of such source code.
//


#include "NamingService.hh"
#include "foo.hh"
#include "foo_impl.h"
#include <stream.h>
#include <stdlib.h>


int main(int argc, char *argv[]){


  CosNaming::NamingContext_var rootContext;

  foo_var foo1 = new foo_impl;
  foo_var foo2 = new foo_impl;

  if (argc !=2) {
    cerr << "usage: client <hostname>" << endl;
    exit(1);
  }

  cout << "\n\nSimple1 demo start" << endl;

	//
	// Bind to the "root" context object in the Naming Service
	//
  try{
    rootContext = CosNaming::NamingContext::_bind("root:NS", argv[1]);
  }
  catch (CORBA::SystemException &sysEx) {
    cerr << "Unexpected system exception" << endl;
    cerr << &sysEx;
    exit(1);
  } catch(...) {
    cerr << "Bind failed" << endl;
    cerr << "Unexpected exception " << endl;
    exit(1);
  }

  // Bind a context called "test" to the root context:

  CosNaming::Name contextName;
  contextName.length(1);
  contextName[0].id   = (const char*) "test";    // string copied
  contextName[0].kind = (const char*) "my_context"; // string copied    
  // Note on kind: The kind field is used to indicate the type
  // of the object. This is to avoid conventions such as that used
  // by files (name.type -- e.g. test.ps = postscript etc.)
    
  CosNaming::NamingContext_var testContext;
  try {
    // Bind the context to root, and assign testContext to it:
    testContext = rootContext->bind_new_context(contextName);
  }
  catch(CosNaming::NamingContext::AlreadyBound& ex) {
    // If the context already exists, this exception will be raised.
    // In this case, just resolve the name and assign testContext
    // to the object returned:
    CORBA::Object_var tmpobj;
    tmpobj = rootContext->resolve(contextName);
    testContext = CosNaming::NamingContext::_narrow(tmpobj);
    if (CORBA::is_nil(testContext)) {
      cerr << "Failed to narrow naming context." << endl;
      return 0;
    }
  } 
  // Bind the object (obj) to testContext, naming it Echo:

  {// Temporary scope. 
    //
    // Part 1: Bind a couple of names
      //

      CosNaming::Name_var tmpName;
      tmpName = new CosNaming::Name(1); 

      try{
	tmpName->length(1);

	tmpName[0].id = CORBA::string_dupl("Foo1");
	tmpName[0].kind = CORBA::string_dupl("");
	testContext->bind(tmpName,foo1);


	tmpName[0].id = CORBA::string_dupl("Foo2");
	tmpName[0].kind = CORBA::string_dupl("");
	testContext->bind(tmpName,foo2);
      }
      catch (CosNaming::NamingContext::AlreadyBound &ab){
	cout << "Name " << tmpName[0].id << " is already bound" << endl;
	exit(1);
      }
      catch (CosNaming::NamingContext::InvalidName &iv){
	cout << "Name " << tmpName[0].id << " is invalid" << endl;
	exit(1);
      }
      catch (CORBA::SystemException &sysEx) {
	cerr << "Unexpected system exception" << endl;
	cerr << &sysEx;
	exit(1);
      } catch(...) {
	cerr << "Unexpected exception " << endl;
	exit(1);
      }
    }


    {// Temporary scope. 

      //
      // Part 2: Resolve those names
      //

      CORBA::Object_var tmpObj1;
      CORBA::Object_var tmpObj2;
      //CosNaming::Name_var tmpName;
      //tmpName = new CosNaming::Name(1); 

      // Create a name object, containing the name test/context:
      CosNaming::Name tmpName;
      tmpName.length(2);

      try{
	//tmpName->length(1);
	//tmpName[0].id = CORBA::string_dupl("Foo1");
	//tmpName[0].kind = CORBA::string_dupl("");
	tmpName[0].id   = CORBA::string_dupl("test");       // string copied
	tmpName[0].kind = CORBA::string_dupl("my_context"); // string copied
	tmpName[1].id   = CORBA::string_dupl("Foo1");
	tmpName[1].kind = CORBA::string_dupl("");

	tmpObj1 = rootContext->resolve(tmpName);

	tmpName[0].id   = CORBA::string_dupl("test");       // string copied
	tmpName[0].kind = CORBA::string_dupl("my_context"); // string copied
	tmpName[1].id   = CORBA::string_dupl("Foo2");
	tmpName[1].kind = CORBA::string_dupl("");

	tmpObj2 = rootContext->resolve(tmpName);

      }
      catch (CosNaming::NamingContext::NotFound &ab){
	cout << "Could not resolve " << tmpName[0].id << endl;
	exit(1);
      }
      catch (CosNaming::NamingContext::InvalidName &iv){
	cout << "Invalid name on CosNaming::NamingContext::bind" << endl;
	exit(1);
      }
      catch (CORBA::SystemException &sysEx) {
	cerr << "Unexpected system exception" << endl;
	cerr << &sysEx;
	exit(1);
      } catch(...) {
	cerr << "Unexpected exception " << endl;
	exit(1);
      }

      //
      // Check results
      //
      CORBA::String_var str1 =
(tmpObj1->_object_to_string());CORBA::IT_INTEROPERABLE_OR_KIND));
      CORBA::String_var str2 = (foo1->_object_to_string());
      if (!strcmp(str1,str2)){
	cout << "Name Foo1 in the root context resolved to " 
	     << str1 << " as expected" << endl;
      }
      else{
	cout << "Error resolving Foo1 in the root context" << endl;
      }

      str1 = (tmpObj2->_object_to_string());
      str2 = (foo2->_object_to_string());
      if (!strcmp(str1,str2)){
	cout << "Name Foo2 in the root context resolved to " 
	     << str2 << " as expected" << endl;
      }
      else{
	cout << "Error resolving Foo2 in the root context" << endl;
      }
		      
    }

    {// Temporary scope. 

      //
      // Part 3: Finally unbind those names.
      //


      CosNaming::Name_var tmpName;
      tmpName = new CosNaming::Name(1); 

      try{
	tmpName->length(1);

	tmpName[0].id = CORBA::string_dupl("Foo1");
	tmpName[0].kind = CORBA::string_dupl("");
	// rootContext->unbind(tmpName);

	tmpName[0].id = CORBA::string_dupl("Foo2");
	tmpName[0].kind = CORBA::string_dupl("");
	// rootContext->unbind(tmpName);
      }
      catch (CORBA::SystemException &sysEx) {
	cerr << "Unexpected system exception" << endl;
	cerr << &sysEx;
	exit(1);
      } catch(...) {
	cerr << "Unexpected exception " << endl;
	exit(1);
      }
    }


    cout << "Simple1 demo end" << endl;
    return 0;
  }

-----------------------------------------------------------------------

-- 
 -mb-